From e0ff1a51fd8d518c2a44cc3e299cb582b7d30b51 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Tue, 15 Sep 2026 07:58:51 +0200 Subject: [PATCH] Integrated events and should close flag. --- src/game.odin | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/game.odin b/src/game.odin index ec86d77..306ba2b 100644 --- a/src/game.odin +++ b/src/game.odin @@ -12,6 +12,7 @@ Game :: struct { viewport: rl.RenderTexture2D, scene: Scene, overlay_scene: Maybe(Scene), + should_close: bool, } // ------------------------------------------------------------------------------ @@ -21,11 +22,13 @@ game_init :: proc(game: ^Game) { rl.InitWindow(WINDOW_W, WINDOW_H, WINDOW_TITLE) rl.SetTargetFPS(60) - game.viewport = rl.LoadRenderTexture(VIEWPORT_W, VIEWPORT_H) - game.scene = make_gameplay_scene() - // game.scene = make_main_menu() + // allocate some event capacity to stop early dynamic reallocations + GLOBAL_EVENTS = make([dynamic]Event, 0, 16) - debug_init() + game.viewport = rl.LoadRenderTexture(VIEWPORT_W, VIEWPORT_H) + game.scene = make_main_menu() + game.overlay_scene = nil + game.should_close = false } game_update :: proc(game: ^Game) { @@ -64,13 +67,15 @@ game_render :: proc(game: ^Game) { rl.EndDrawing() } + game_quit :: proc(game: ^Game) { + delete(GLOBAL_EVENTS) rl.UnloadRenderTexture(game.viewport) rl.CloseWindow() } -game_should_run :: proc() -> bool { - return !rl.WindowShouldClose() +game_should_run :: proc(game: Game) -> bool { + return !game.should_close && !rl.WindowShouldClose() } // ------------------------------------------------------------------------------