menu: mode clickable
This commit is contained in:
parent
33c48e4538
commit
118c9e7168
39
main.c
39
main.c
|
@ -27,10 +27,12 @@ char game[16][30] = {0};
|
||||||
char discover[16][30] = {0};
|
char discover[16][30] = {0};
|
||||||
char zero[16][30] = {0};
|
char zero[16][30] = {0};
|
||||||
|
|
||||||
|
// I confused myself with game type, mode and diff, but it all mean the same
|
||||||
typedef enum GameType {
|
typedef enum GameType {
|
||||||
BEGINNER,
|
BEGINNER,
|
||||||
INTERMEDIATE,
|
INTERMEDIATE,
|
||||||
EXPERT,
|
EXPERT,
|
||||||
|
GAME_TYPE_NB,
|
||||||
} GameType;
|
} GameType;
|
||||||
|
|
||||||
GameType current_game_type = BEGINNER;
|
GameType current_game_type = BEGINNER;
|
||||||
|
@ -240,6 +242,25 @@ void reload_game(void)
|
||||||
screen_resize_handle();
|
screen_resize_handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switch_mode(GameType gt)
|
||||||
|
{
|
||||||
|
current_game_type = gt;
|
||||||
|
switch (gt) {
|
||||||
|
case BEGINNER:
|
||||||
|
current_game_name = "beginner";
|
||||||
|
current_game_color = GREEN;
|
||||||
|
break;
|
||||||
|
case INTERMEDIATE:
|
||||||
|
current_game_name = "intermediate";
|
||||||
|
current_game_color = ORANGE;
|
||||||
|
break;
|
||||||
|
case EXPERT:
|
||||||
|
current_game_name = "expert";
|
||||||
|
current_game_color = RED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
@ -304,21 +325,15 @@ int main(void)
|
||||||
|
|
||||||
int resize = 0;
|
int resize = 0;
|
||||||
if (IsKeyPressed(KEY_I)) {
|
if (IsKeyPressed(KEY_I)) {
|
||||||
current_game_type = INTERMEDIATE;
|
switch_mode(INTERMEDIATE);
|
||||||
current_game_name = "intermediate";
|
|
||||||
current_game_color = ORANGE;
|
|
||||||
resize = 1;
|
resize = 1;
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(KEY_B)) {
|
if (IsKeyPressed(KEY_B)) {
|
||||||
current_game_type = BEGINNER;
|
switch_mode(BEGINNER);
|
||||||
current_game_name = "beginner";
|
|
||||||
current_game_color = GREEN;
|
|
||||||
resize = 1;
|
resize = 1;
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(KEY_E)) {
|
if (IsKeyPressed(KEY_E)) {
|
||||||
current_game_type = EXPERT;
|
switch_mode(EXPERT);
|
||||||
current_game_name = "expert";
|
|
||||||
current_game_color = RED;
|
|
||||||
resize = 1;
|
resize = 1;
|
||||||
}
|
}
|
||||||
if (resize || IsKeyPressed(KEY_R)) {
|
if (resize || IsKeyPressed(KEY_R)) {
|
||||||
|
@ -490,6 +505,12 @@ int main(void)
|
||||||
{
|
{
|
||||||
take_screenshot = 1;
|
take_screenshot = 1;
|
||||||
}
|
}
|
||||||
|
if (collision((Vec2i) {0, 0}, triple_tile_texture,
|
||||||
|
mouse_x, mouse_y))
|
||||||
|
{
|
||||||
|
switch_mode((current_game_type + 1) % GAME_TYPE_NB);
|
||||||
|
reload_game();
|
||||||
|
}
|
||||||
// if (collision(diff_button[0], triple_tile_texture,
|
// if (collision(diff_button[0], triple_tile_texture,
|
||||||
// mouse_x, mouse_y))
|
// mouse_x, mouse_y))
|
||||||
// {
|
// {
|
||||||
|
|
Loading…
Reference in New Issue