Skip to content

Commit

Permalink
fix seamless song loading
Browse files Browse the repository at this point in the history
  • Loading branch information
UNSTOP4BLE committed Jul 7, 2024
1 parent 6608a20 commit dac4324
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 14 deletions.
Binary file modified assets/menu/story/Unsaved Image 3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/menu/story/campaign_menu_UI_characters.png
Binary file not shown.
23 changes: 23 additions & 0 deletions assets/menu/story/characters/bf/frames.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"textures": [
"sheet0.png"
],
"frames": [
[0, 242, 1, 78, 75, 0, 0],
[0, 322, 1, 78, 75, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],

[0, 1, 1, 76, 80, 0, 0],
[0, 79, 1, 79, 79, 0, 0],
[0, 160, 1, 80, 79, 0, 0],

[0, 0, 0, 0, 0, 0, 0]
],

"config": [
[24, 0, 1, 2, 3, 4],
[24, 5, 6, 7]
]
}
16 changes: 9 additions & 7 deletions src/menu/storymode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ StoryModeScreen::StoryModeScreen(int songpos) {
freaky = new Audio::StreamedFile(*app->audioMixer, getPath("assets/music/freaky/freaky.ogg").c_str());
freaky->play(true);
freaky->setPosition(songpos);
background = new GFX::Texture();
background->load(getPath("assets/menu/back.png").c_str());
selection = 0;
}

Expand Down Expand Up @@ -43,15 +41,19 @@ void StoryModeScreen::update(void)

void StoryModeScreen::draw(void)
{
GFX::RECT<int> background_img = {0, 0, 512, 331};
GFX::RECT<float> background_disp = {app->screenwidth/2 - 700/2, app->screenheight/2 - 397/2, 700, 397};
GFX::drawTex<float>(background, &background_img, &background_disp, 0, 255, 1);
GFX::RECT<int> black_background = {0, 0, app->screenwidth, app->screenheight};
GFX::drawRect(&black_background, 1, 0, 0, 0);
GFX::RECT<int> middle_strap = {0, 21, app->screenwidth, 152};
GFX::drawRect(&middle_strap, 1, 247, 208, 81);

app->normalFont->Print(Left, 50, 50, "only week 1 currently available \n(press x to start)");
app->normalFont->Print(Left, 5, 6, "WEEK SCORE: ");
app->normalFont->Print(Left, 51, 191, "TRACKS");
app->normalFont->Print(Center, 51, 213, "TEST");
app->normalFont->Print(Center, 51, 213+10, "TESTTESTTEST");
app->normalFont->Print(Left, 50, 50, "only week 1 currently available \n(press x to start)");
}

StoryModeScreen::~StoryModeScreen(void)
{
delete background;
delete freaky;
}
1 change: 0 additions & 1 deletion src/menu/storymode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class StoryModeScreen : public Screen {
void draw(void);
~StoryModeScreen(void);
private:
GFX::Texture *background;
Audio::StreamedFile *freaky;
//selections
int selection;
Expand Down
13 changes: 9 additions & 4 deletions src/playstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ void PlayStateScreen::update(void)
if ((nextsong == "NULL" || nextsong == "null"))
setScreen(new StoryModeScreen(0));
else
setScreen(new PlayStateScreen(nextsong, false));
{
delete app->currentScreen;
app->currentScreen = NULL;
std::string next = nextsong;
setScreen(new PlayStateScreen(next, false));
}
}
return;
}
Expand Down Expand Up @@ -411,11 +416,11 @@ void PlayStateScreen::missedNote(int pos) {

if (pos != 0) { //sustain
int notediff = pos - app->parser.songTime;
if (notediff < 0 && (notediff % 8) == 0)
health -= 0.05/2;
// if (notediff < 0 && (notediff % 8) == 0)
// health -= 0.05/2;
}
else { //normal note
health -= 0.05;
// health -= 0.05;
misses += 1;
combo.combo = 0;
}
Expand Down
2 changes: 0 additions & 2 deletions src/psp/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ Anim_OBJECT::~Anim_OBJECT(void)
{
for (int i = 0; i < static_cast<int>(textures.size()); i++)
{
if (textures.size() == 0)
return;
delete textures[i];
textures[i] = nullptr;
}
Expand Down
5 changes: 5 additions & 0 deletions src/psp/gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ typedef enum
SDL_ScaleModeBest < anisotropic filtering
} SDL_ScaleMode;
*/
void drawRect(GFX::RECT<int> *Disp, float zoom, uint8_t r, uint8_t g, uint8_t b) {
SDL_Rect zoomDisp = {static_cast<int>((Disp->x * zoom) + (app->screenwidth * (1 - zoom) / 2)), static_cast<int>((Disp->y * zoom) + (app->screenheight * (1 - zoom) / 2)), static_cast<int>(Disp->w * zoom), static_cast<int>(Disp->h * zoom)};
SDL_SetRenderDrawColor(app->renderer, r, g, b, 255);
SDL_RenderFillRect(app->renderer, &zoomDisp);
}

template<typename T> void drawTex(Texture* tex, GFX::RECT<int> *Img, GFX::RECT<T> *Disp, float angle, int alpha, float zoom) {
RECT<T> zoomDisp = {static_cast<T>((Disp->x * zoom) + (app->screenwidth * (1 - zoom) / 2)), static_cast<T>((Disp->y * zoom) + (app->screenheight * (1 - zoom) / 2)), static_cast<T>(Disp->w * zoom), static_cast<T>(Disp->h * zoom)};
Expand Down
1 change: 1 addition & 0 deletions src/psp/gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Texture {
void init(void);
void clear(int color);
void flip(void);
void drawRect(GFX::RECT<int> *Disp, float zoom, uint8_t r, uint8_t g, uint8_t b);
template<typename T> void drawTex(Texture* tex, GFX::RECT<int> *Img, GFX::RECT<T> *Disp, float angle, int alpha, float zoom);
template<typename T> void drawColTex(Texture* tex, GFX::RECT<int> *Img, GFX::RECT<T> *Disp, float angle, int alpha, float zoom, uint8_t r, uint8_t g, uint8_t b);
};

0 comments on commit dac4324

Please sign in to comment.