Skip to content

Commit

Permalink
Merge pull request #69 from 8enrich/Intro
Browse files Browse the repository at this point in the history
Intro
  • Loading branch information
dabzr authored Sep 5, 2024
2 parents af99cd5 + 6893e0d commit 77c18a7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Binary file added assets/intro.mp3
Binary file not shown.
2 changes: 2 additions & 0 deletions include/Menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ class Menu : public Screen {
ScreenButton Stats = ScreenButton(Vec2<double>{1.0f/1.08, 1.0f/50}, STATS, "stats.png");
const std::vector<Button*> buttons = { &Solo, &Coop, &Options, &Quit, &Stats };
ButtonManager buttonManager = ButtonManager(buttons);
bool isFirstEntrance = true;
void Intro();
};
35 changes: 35 additions & 0 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Menu::~Menu(){
delete logoTexture;
}
void Menu::Tick(){
if(isFirstEntrance) Intro();
OptionsHandling();
BeginDrawing();
Draw();
Expand All @@ -35,3 +36,37 @@ void Menu::OptionsHandling(){
OpenClose();
}
}

void Menu::Intro(){
std::vector<std::string> texts = {"A dabzr & 8enrich production", "Sound by Daniel Santos & Art by José Iramar"};
Sound intro = LoadSound((std::string(ASSETS_PATH)+ "intro.mp3").c_str());
PlaySound(intro);
int value = 0;
Color tipColor = Color{255, 255, 255, 0};
Color color = Color{255, 255, 255, 0};
float posY = 1.0f/2;
for(int i = 0; i < 3; i++){
if(i) value = 115 + (i - 1) * 100;
for(int j = 0; j < 340 - value; j++){
int key = GetKeyPressed();
if(key == KEY_ENTER){
isFirstEntrance = false;
StopSound(intro);
return;
}
if(key != KEY_NULL) tipColor.a = 255;
BeginDrawing();
ClearBackground(BLACK);
ray_functions::DrawFormatedText("Press Enter to Skip ->", Vec2<double>{1.0f/1.15, 1.0f/1.1}, 1.0f/30, tipColor);
if(i < 2) ray_functions::DrawFormatedText(texts[i].c_str(), Vec2<double>{1.0f/2, 1.0f/2}, 1.0f/20, color);
else ray_functions::DrawScaledImage(logoTexture, {1.0f/2, posY}, 0.5);
EndDrawing();
if(tipColor.a != 0 && tipColor.a > 3)tipColor.a-=3;
if(!i && j < 115) continue;
if(j < 240 - value && color.a < 254) color.a+=2;
else if (color.a >= 3) color.a-=3;
if(i == 2 && j > 20 && posY > 1.0f/3) posY-=0.0016;
}
}
isFirstEntrance = false;
}

0 comments on commit 77c18a7

Please sign in to comment.