#include "game/settings.h"
#include "game/credits.h"
-typedef enum Game_state {
- GAME_STATE_LEVEL = 0,
- GAME_STATE_LEVEL_PICKER,
- GAME_STATE_LEVEL_EDITOR,
- GAME_STATE_CREDITS,
- GAME_STATE_SETTINGS,
- GAME_STATE_QUIT
-} Game_state;
typedef struct Game {
Lt *lt;
int console_enabled;
} Game;
-static
void game_switch_state(Game *game, Game_state state)
{
game->camera = create_camera(game->renderer, game->font);
return -1;
}
- level_picker_clean_selection(game->level_picker);
game_switch_state(game, GAME_STATE_LEVEL);
} break;
} break;
}
} break;
- case SDL_KEYDOWN: {
- switch (event->key.keysym.sym) {
- case SDLK_ESCAPE: {
- if (game->state == GAME_STATE_LEVEL) {
- game_switch_state(game, GAME_STATE_LEVEL_PICKER);
- }
- } break;
- }
- } break;
}
}
return -1;
}
- level_picker_clean_selection(game->level_picker);
game_switch_state(game, GAME_STATE_LEVEL);
return 0;
int game_over_check(const Game *game);
+typedef enum Game_state {
+ GAME_STATE_LEVEL = 0,
+ GAME_STATE_LEVEL_PICKER,
+ GAME_STATE_LEVEL_EDITOR,
+ GAME_STATE_CREDITS,
+ GAME_STATE_SETTINGS,
+ GAME_STATE_QUIT
+} Game_state;
+
+void game_switch_state(Game *game, Game_state state);
int game_load_level(Game *game, const char *filepath);
// defined in main.c. is there a better place for this to be declared?
if (game_load_level(console->game, level_name) < 0) {
console_log_push_line(console->console_log, "Could not load level", NULL, CONSOLE_ERROR);
}
+ } else if (token_equals_str(command, "menu")) {
+ console_log_push_line(console->console_log, "Loading menu", NULL, CONSOLE_FOREGROUND);
+ level_picker_clean_selection(console->game->level_picker);
+ game_switch_state(console->game, GAME_STATE_LEVEL_PICKER);
} else {
console_log_push_line(console->console_log, "Unknown command", NULL, CONSOLE_ERROR);
}