set up game loop

This commit is contained in:
2026-07-01 00:31:42 -07:00
parent 574bb14d5b
commit bb25247c43
2 changed files with 33 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package main
import rl "vendor:raylib"
Game :: struct {
running: bool,
time: f32, // total time elapsed
}
game_init :: proc() -> Game {
return Game{running = true, time = 0}
}
game_update :: proc(g: ^Game, dt: f32) {
g.time += dt
if rl.IsKeyPressed(.ESCAPE) {
g.running = false
}
}
game_draw :: proc(g: ^Game) {
fps := rl.GetFPS()
rl.DrawText(rl.TextFormat("FPS: %i", fps), 10, 36, 20, rl.GREEN)
rl.DrawText(rl.TextFormat("Time: %.1fs", g.time), 10, 62, 20, rl.GRAY)
}