Big initial commit: States, simulation, presentation, menus, some art.
This commit is contained in:
53
src/main.c
Normal file
53
src/main.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "presentation/states/state_ingame.h"
|
||||
#include "presentation/states/state_main_menu.h"
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main() {
|
||||
InitWindow(1280, 720, "snejk");
|
||||
SetTargetFPS(60);
|
||||
SetExitKey(KEY_NULL);
|
||||
|
||||
bool should_quit_game = false;
|
||||
|
||||
Presentation_State_Ingame_Context presentation_state_ingame_ctx = (Presentation_State_Ingame_Context) {
|
||||
};
|
||||
Presentation_State_Main_Menu_Context presentation_state_main_menu_ctx = {
|
||||
.should_quit_game = &should_quit_game,
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Presentation_State *state = presentation_state_machine.current;
|
||||
|
||||
// Tick.
|
||||
if(state != NULL && state->tick != NULL) {
|
||||
state->tick(state);
|
||||
}
|
||||
|
||||
// Render.
|
||||
BeginDrawing();
|
||||
{
|
||||
if(state != NULL && state->render != NULL) {
|
||||
state->render(state);
|
||||
}
|
||||
}
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
assert(presentation_state_machine_go_to(NULL));
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user