Small comment cleanup and initial use of entites.

This commit is contained in:
2026-09-07 07:54:21 +02:00
parent abd6f0a81f
commit 85417a6335
2 changed files with 29 additions and 3 deletions
+26 -2
View File
@@ -15,7 +15,9 @@ State :: enum {
}
Game :: struct {
state: State
state: State,
player: Entity,
enemy: Entity
}
// @NOTE: procs ie: game_init, game should run etc is a convention to work with wasm
@@ -25,20 +27,42 @@ game_init :: proc(game: ^Game) {
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE)
rl.SetTargetFPS(60)
game.state = .IN_GAME
game.state = .IN_GAME
game.player = init_player()
}
game_update :: proc(game: ^Game) {
// get delta time for frame
dt := rl.GetFrameTime()
#partial switch game.state {
case .IN_GAME: update_gameplay(dt, game)
}
}
game_render :: proc(game: ^Game) {
rl.BeginDrawing()
rl.ClearBackground(rl.DARKGRAY)
#partial switch game.state {
case .IN_GAME: render_gameplay(game)
}
rl.EndDrawing()
}
game_quit :: proc(game: ^Game) {
rl.CloseWindow()
}
update_gameplay :: proc(dt: f32, game: ^Game) {
// game not paused for each component, ie player, enemies, environment
// run update functions here.
update_player(dt, &game.player)
// update_camera
// update_entities
}
render_gameplay :: proc(game: ^Game) {
render_player(game.player)
}
+3 -1
View File
@@ -19,15 +19,17 @@ main :: proc() {
}
// ------------------------------------------------------
// Game Start
game := Game{}
game_init(&game)
// Game loop
for game_should_run() {
game_update(&game)
game_render(&game)
}
// Game Stop
game_quit(&game)
// ------------------------------------------------------