Skip to content

Commit

Permalink
progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
3drosalia committed Apr 25, 2024
1 parent 2012d4c commit 5104135
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
8 changes: 5 additions & 3 deletions Encore/include/game/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Assets {
Texture2D star;
Texture2D goldStar;

Font rubik32;
Font rubik;
Font redHatDisplayItalic;

Expand Down Expand Up @@ -157,21 +158,22 @@ class Assets {
noteModelOD = LoadModel((directory / "Assets/notes/note.obj").string().c_str());
noteTextureOD = LoadTextureFilter(directory / "Assets/notes/note.png");
emitTextureOD = LoadTextureFilter(directory / "Assets/notes/note_e_new.png");
noteModelOD.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = noteTextureOD;
// noteModelOD.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = noteTextureOD;
noteModelOD.materials[0].maps[MATERIAL_MAP_ALBEDO].color = WHITE;
noteModelOD.materials[0].maps[MATERIAL_MAP_EMISSION].texture = emitTextureOD;
noteModelOD.materials[0].maps[MATERIAL_MAP_EMISSION].color = WHITE;
liftModel = LoadModel((directory / "Assets/notes/lift.obj").string().c_str());
liftModel.materials[0].maps[MATERIAL_MAP_ALBEDO].color = Color{ 172,82,217,127 };
liftModel.materials[0].maps[MATERIAL_MAP_ALBEDO].color = player.accentColor;
liftModelOD = LoadModel((directory / "Assets/notes/lift.obj").string().c_str());
liftModelOD.materials[0].maps[MATERIAL_MAP_ALBEDO].color = Color{ 217, 183, 82 ,127 };
liftModelOD.materials[0].maps[MATERIAL_MAP_ALBEDO].color = WHITE;

icon = LoadImage((directory / "Assets/encore_favicon-NEW.png").string().c_str());
encoreWhiteLogo = LoadTexture((directory / "Assets/encore-white.png").string().c_str());
songBackground = LoadTexture((directory / "Assets/background.png").string().c_str());

redHatDisplayItalic = LoadFontEx((directory/"Assets/fonts/RedHatDisplay-BlackItalic.ttf").string().c_str(), 48,0,0);
rubik = LoadFontEx((directory / "Assets/fonts/Rubik-Regular.ttf").string().c_str(), 100, 0, 0);
rubik32 = LoadFontEx((directory / "Assets/fonts/Rubik-Regular.ttf").string().c_str(), 32, 0, 0);
//clapOD = LoadSound((directory / "Assets/highway/clap.ogg").string().c_str());
//SetSoundVolume(clapOD, 0.375);
}
Expand Down
41 changes: 35 additions & 6 deletions Encore/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,18 @@ int pressedGamepadInput = -999;
int axisDirection = -1;
int controllerID = -1;

static void DrawTextRubik32(const char* text, float posX, float posY, Color color) {
DrawTextEx(assets.rubik32, text, { posX,posY }, 32, 2, color);
}
static void DrawTextRubik(const char* text, float posX, float posY, int fontSize, Color color) {
DrawTextEx(assets.rubik, text, { posX,posY }, fontSize, 2, color);
}
static void DrawTextRHDI(const char* text, float posX, float posY, Color color) {
DrawTextEx(assets.redHatDisplayItalic, text, { posX,posY }, 48, 2, color);
}

static int MeasureTextRubik32(const char* text) {
return MeasureTextEx(assets.rubik, text, 32, 2).x;
}
static int MeasureTextRubik(const char* text, int fontSize) {
return MeasureTextEx(assets.rubik, text, fontSize, 2).x;
}
Expand Down Expand Up @@ -1004,6 +1009,7 @@ int main(int argc, char* argv[])
case GAMEPLAY: {
// IMAGE BACKGROUNDS??????
ClearBackground(BLACK);

DrawTextureEx(assets.songBackground, {0,0},0, (float)GetScreenHeight()/assets.songBackground.height,WHITE);
int starsval = stars(songList.songs[curPlayingSong].parts[instrument]->charts[diff].baseScore);
for (int i = 0; i < 5; i++) {
Expand Down Expand Up @@ -1086,6 +1092,17 @@ int main(int argc, char* argv[])
player::resetPlayerStats();
}
else {
float songPlayed = GetMusicTimePlayed(loadedStreams[0].first);
int songLength = GetMusicTimeLength(loadedStreams[0].first);
int playedMinutes = GetMusicTimePlayed(loadedStreams[0].first)/60;
int playedSeconds = (int)GetMusicTimePlayed(loadedStreams[0].first) % 60;
int songMinutes = GetMusicTimeLength(loadedStreams[0].first)/60;
int songSeconds = (int)GetMusicTimeLength(loadedStreams[0].first) % 60;

const char* textTime = TextFormat("%i:%02i / %i:%02i ", playedMinutes,playedSeconds,songMinutes,songSeconds);
int textLength = MeasureTextRubik32(textTime);

DrawTextRubik32(textTime,GetScreenWidth() - textLength,GetScreenHeight()-40,WHITE);
if (GetTime() >= GetMusicTimeLength(loadedStreams[0].first) + startedPlayingSong) {
for (Note& note : songList.songs[curPlayingSong].parts[instrument]->charts[diff].notes) {
note.accounted = false;
Expand Down Expand Up @@ -1321,24 +1338,24 @@ int main(int argc, char* argv[])
}*/

if (curNote.held && !curNote.renderAsOD) {
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 230,100,230,255 });
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, player.accentColor);
}
if (curNote.renderAsOD && curNote.held) {
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 255, 255, 180 ,255 });
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 255, 255, 255 ,255 });
}
if (!curNote.held && curNote.hit || curNote.miss) {
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 69,69,69,255 });
}
if (!curNote.hit && !curNote.accounted && !curNote.miss) {
if (curNote.renderAsOD) {
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 200, 170, 70 ,255 });
DrawCylinderEx(Vector3{ notePosX, 0.05f, smasherPos + (highwayLength * (float)relTime) }, Vector3{ notePosX,0.05f, smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15, Color{ 200, 200, 200 ,255 });
}
else {
DrawCylinderEx(Vector3{ notePosX, 0.05f,
smasherPos + (highwayLength * (float)relTime) },
Vector3{ notePosX, 0.05f,
smasherPos + (highwayLength * (float)relEnd) }, 0.1f, 0.1f, 15,
Color{ 150, 19, 150, 255 });
player.accentColor);
}
}

Expand Down Expand Up @@ -1397,7 +1414,19 @@ int main(int argc, char* argv[])
// DrawTriangle3D(Vector3{ diffDistance + 0.5f,0.05f,smasherPos - (highwayLength * perfectBackend * trackSpeed[speedSelection]) }, Vector3{ -diffDistance - 0.5f,0.05f,smasherPos - (highwayLength * perfectBackend * trackSpeed[speedSelection]) }, Vector3{ -diffDistance - 0.5f,0.05f,smasherPos + (highwayLength * perfectFrontend * trackSpeed[speedSelection]) }, Color{ 190,255,0,80 });
#endif
EndMode3D();
break;

float songPlayed = GetMusicTimePlayed(loadedStreams[0].first);
int songLength = GetMusicTimeLength(loadedStreams[0].first);
int playedMinutes = GetMusicTimePlayed(loadedStreams[0].first)/60;
int playedSeconds = (int)GetMusicTimePlayed(loadedStreams[0].first) % 60;
int songMinutes = GetMusicTimeLength(loadedStreams[0].first)/60;
int songSeconds = (int)GetMusicTimeLength(loadedStreams[0].first) % 60;
const char* textTime = TextFormat("%i:%02i / %i:%02i ", playedMinutes,playedSeconds,songMinutes,songSeconds);
int textLength = MeasureTextRubik32(textTime);

GuiProgressBar(Rectangle {0,(float)GetScreenHeight()-7,(float)GetScreenWidth(),7}, "", "", &songPlayed, 0, songLength);

break;
}
case RESULTS: {
int starsval = stars(songList.songs[curPlayingSong].parts[instrument]->charts[diff].baseScore);
Expand Down

0 comments on commit 5104135

Please sign in to comment.