Integrated events and should close flag.
This commit is contained in:
+11
-6
@@ -12,6 +12,7 @@ Game :: struct {
|
|||||||
viewport: rl.RenderTexture2D,
|
viewport: rl.RenderTexture2D,
|
||||||
scene: Scene,
|
scene: Scene,
|
||||||
overlay_scene: Maybe(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.InitWindow(WINDOW_W, WINDOW_H, WINDOW_TITLE)
|
||||||
rl.SetTargetFPS(60)
|
rl.SetTargetFPS(60)
|
||||||
|
|
||||||
game.viewport = rl.LoadRenderTexture(VIEWPORT_W, VIEWPORT_H)
|
// allocate some event capacity to stop early dynamic reallocations
|
||||||
game.scene = make_gameplay_scene()
|
GLOBAL_EVENTS = make([dynamic]Event, 0, 16)
|
||||||
// game.scene = make_main_menu()
|
|
||||||
|
|
||||||
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) {
|
game_update :: proc(game: ^Game) {
|
||||||
@@ -64,13 +67,15 @@ game_render :: proc(game: ^Game) {
|
|||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
game_quit :: proc(game: ^Game) {
|
game_quit :: proc(game: ^Game) {
|
||||||
|
delete(GLOBAL_EVENTS)
|
||||||
rl.UnloadRenderTexture(game.viewport)
|
rl.UnloadRenderTexture(game.viewport)
|
||||||
rl.CloseWindow()
|
rl.CloseWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
game_should_run :: proc() -> bool {
|
game_should_run :: proc(game: Game) -> bool {
|
||||||
return !rl.WindowShouldClose()
|
return !game.should_close && !rl.WindowShouldClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user