diff --git a/assets/intro.mp3 b/assets/intro.mp3 new file mode 100644 index 0000000..d3cdab6 Binary files /dev/null and b/assets/intro.mp3 differ diff --git a/include/Menu.hpp b/include/Menu.hpp index 70cce49..01512b4 100644 --- a/include/Menu.hpp +++ b/include/Menu.hpp @@ -19,4 +19,6 @@ class Menu : public Screen { ScreenButton Stats = ScreenButton(Vec2{1.0f/1.08, 1.0f/50}, STATS, "stats.png"); const std::vector buttons = { &Solo, &Coop, &Options, &Quit, &Stats }; ButtonManager buttonManager = ButtonManager(buttons); + bool isFirstEntrance = true; + void Intro(); }; diff --git a/src/Menu.cpp b/src/Menu.cpp index 7e7f0ed..ed7b65f 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -15,6 +15,7 @@ Menu::~Menu(){ delete logoTexture; } void Menu::Tick(){ + if(isFirstEntrance) Intro(); OptionsHandling(); BeginDrawing(); Draw(); @@ -35,3 +36,37 @@ void Menu::OptionsHandling(){ OpenClose(); } } + +void Menu::Intro(){ + std::vector 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{1.0f/1.15, 1.0f/1.1}, 1.0f/30, tipColor); + if(i < 2) ray_functions::DrawFormatedText(texts[i].c_str(), Vec2{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; +}