69 lines
2.1 KiB
C
69 lines
2.1 KiB
C
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
#include "presentation/states/state_ingame.h"
|
|
#include "presentation/states/state_main_menu.h"
|
|
|
|
#include "third_party/raylib.h"
|
|
#include "session/networking.h"
|
|
|
|
#include "instance/game_instance.h"
|
|
|
|
int main() {
|
|
InitWindow(1280, 720, "snejk");
|
|
SetTargetFPS(60);
|
|
SetExitKey(KEY_NULL);
|
|
|
|
bool should_quit_game = false;
|
|
|
|
Game_Instance local_game_instance;
|
|
memset(&local_game_instance, 0, sizeof(Game_Instance));
|
|
|
|
game_instance_init(&local_game_instance);
|
|
|
|
Presentation_State_Ingame_Context presentation_state_ingame_ctx;
|
|
memset(&presentation_state_ingame_ctx, 0, sizeof(Presentation_State_Ingame_Context));
|
|
|
|
Presentation_State_Main_Menu_Context presentation_state_main_menu_ctx = {
|
|
.should_quit_game = &should_quit_game,
|
|
.game_instance = &local_game_instance,
|
|
.ingame_ctx = &presentation_state_ingame_ctx
|
|
};
|
|
|
|
presentation_state_ingame_init(&presentation_state_ingame_ctx);
|
|
presentation_state_main_menu_init(&presentation_state_main_menu_ctx);
|
|
|
|
presentation_state_machine_go_to(&presentation_state_main_menu);
|
|
|
|
while(true) {
|
|
if(WindowShouldClose() || should_quit_game) {
|
|
break;
|
|
}
|
|
|
|
// Tick.
|
|
if(presentation_state_machine.current != NULL && presentation_state_machine.current->tick != NULL) {
|
|
presentation_state_machine.current->tick(presentation_state_machine.current);
|
|
}
|
|
|
|
// if(IsKeyPressed(KEY_F)) { // TODO: SS - Add this back, but not 'F'.
|
|
// ToggleFullscreen();
|
|
// }
|
|
|
|
// Render.
|
|
BeginDrawing();
|
|
{
|
|
if(presentation_state_machine.current != NULL && presentation_state_machine.current->render != NULL) {
|
|
presentation_state_machine.current->render(presentation_state_machine.current);
|
|
}
|
|
}
|
|
EndDrawing();
|
|
}
|
|
|
|
assert(presentation_state_machine_go_to(NULL));
|
|
CloseWindow();
|
|
|
|
game_instance_dispose(&local_game_instance);
|
|
|
|
return 0;
|
|
} |