Avoid/src/Title.c

73 lines
2.4 KiB
C
Raw Normal View History

/*
- Avoid ~ a game by Canneddonuts
2022-07-19 15:04:05 +00:00
- Filename ~ Title.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#include "Screens.h"
#include "Controls.h"
2022-09-20 23:28:31 +00:00
#include "Music.h"
#include "Options.h"
2022-08-05 15:31:55 +00:00
#include "Gfx.h"
2022-07-19 15:04:05 +00:00
int titleSelected = 0, finishfromTitleScreen = 0;
2022-09-20 23:28:31 +00:00
Music Titlesong = { 0 };
2022-06-17 02:17:26 +00:00
void InitTitleScreen(void)
{
2022-09-04 15:15:22 +00:00
titleSelected = 0;
2022-07-19 15:04:05 +00:00
finishfromTitleScreen = 0;
2022-09-20 23:28:31 +00:00
Titlesong = LoadMusicStream("assets/bgm/04-Distant-Misadventure.ogg");
PlayMusicStream(Titlesong);
2022-06-17 02:17:26 +00:00
}
void UpdateTitleScreen(void)
{
2022-09-20 23:28:31 +00:00
if (!mute) UpdateMusicStream(Titlesong);
if (INPUT_UP_PRESSED) titleSelected++;
if (INPUT_DOWN_PRESSED) titleSelected--;
if (titleSelected > 0) titleSelected--;
if (titleSelected < -2) titleSelected++;
2022-09-20 23:28:31 +00:00
if ((titleSelected == 0) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 2; }
if ((titleSelected == -1) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 1; }
if ((titleSelected == -2) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 3; }
}
void DrawTitleScreen(void)
{
2022-06-17 02:17:26 +00:00
DrawTexture(background, 0, 0, GRAY);
2022-08-05 15:31:55 +00:00
DrawTextEx(ZadoBold, "Avoid", (Vector2){ 300, 0 }, 80, 5, BLUE);
2022-08-31 19:15:32 +00:00
DrawText("Controls", 5, 10, 30, BLUE);
DrawText("Press the arrow keys or 'DPAD' to move and 'X' to dash", 5, 40, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to pause", 5, 60, 10, WHITE);
DrawText("Press 'M' to mute", 5, 80, 10, WHITE);
DrawText("Press 'Left-ALT' + 'F' for full screen", 5, 100, 10, WHITE);
DrawText("Press 'R' to restart", 5, 120, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to select an option", 5, 140, 10, WHITE);
DrawText("Press 'X' or 'A' on a gamepad to shoot", 5, 160, 10, WHITE);
// DrawText("Ver: 0.1", 680, 420, 30, WHITE);
2022-08-05 15:31:55 +00:00
if (titleSelected == 0) DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, BLUE);
2022-08-05 15:31:55 +00:00
if (titleSelected == -1) DrawTextEx(ZadoBold, "CREDITS", (Vector2){ 330, 250 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "CREDITS", (Vector2){ 330, 250 }, 30, 2, BLUE);
2022-08-05 15:31:55 +00:00
if (titleSelected == -2) DrawTextEx(ZadoBold, "OPTIONS", (Vector2){ 330, 280 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "OPTIONS", (Vector2){ 330, 280 }, 30, 2, BLUE);
}
2022-06-17 02:17:26 +00:00
void UnloadTitleScreen(void)
{
2022-09-20 23:28:31 +00:00
UnloadMusicStream(Titlesong);
2022-07-19 15:04:05 +00:00
}
int FinishTitleScreen(void)
{
return finishfromTitleScreen;
2022-06-17 02:17:26 +00:00
}