Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intro #69

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}