Avoid/src/Title.c

82 lines
2.6 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"
#include "Score.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-06-19 21:36:26 +00:00
void DrawScore(void)
{
2022-07-04 01:08:45 +00:00
if (bestscore >= 10000)
2022-08-31 19:15:32 +00:00
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, (Color){ 222, 181, 0, 255 });
2022-07-04 01:08:45 +00:00
else if (bestscore >= 5000)
2022-08-31 19:15:32 +00:00
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, (Color){ 149, 148, 147, 255 });
2022-07-04 01:08:45 +00:00
else if (bestscore >= 1000)
2022-08-31 19:15:32 +00:00
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30,(Color){ 138, 72, 4, 255 });
2022-07-04 01:08:45 +00:00
else
2022-08-31 19:15:32 +00:00
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, BLUE);
2022-06-19 21:36:26 +00:00
}
2022-07-19 15:04:05 +00:00
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-06-17 02:17:26 +00:00
}
void UpdateTitleScreen(void)
{
if (INPUT_UP_PRESSED) titleSelected++;
if (INPUT_DOWN_PRESSED) titleSelected--;
if (titleSelected > 0) titleSelected--;
if (titleSelected < -2) titleSelected++;
2022-07-19 15:04:05 +00:00
if ((titleSelected == 0) && (INPUT_OPTION_PRESSED)) finishfromTitleScreen = 2;
if ((titleSelected == -1) && (INPUT_OPTION_PRESSED)) finishfromTitleScreen = 1;
if ((titleSelected == -2) && (INPUT_OPTION_PRESSED)) 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);
2022-07-19 15:04:05 +00:00
DrawScore();
2022-08-31 19:15:32 +00:00
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-07-19 15:04:05 +00:00
}
int FinishTitleScreen(void)
{
return finishfromTitleScreen;
2022-06-17 02:17:26 +00:00
}