Integrated events and should close flag.
This commit is contained in:
+11
-6
@@ -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()
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user