Small comment cleanup and initial use of entites.
This commit is contained in:
+26
-2
@@ -15,7 +15,9 @@ State :: enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Game :: struct {
|
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
|
// @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.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE)
|
||||||
rl.SetTargetFPS(60)
|
rl.SetTargetFPS(60)
|
||||||
|
|
||||||
game.state = .IN_GAME
|
game.state = .IN_GAME
|
||||||
|
game.player = init_player()
|
||||||
}
|
}
|
||||||
|
|
||||||
game_update :: proc(game: ^Game) {
|
game_update :: proc(game: ^Game) {
|
||||||
// get delta time for frame
|
// get delta time for frame
|
||||||
dt := rl.GetFrameTime()
|
dt := rl.GetFrameTime()
|
||||||
|
|
||||||
|
#partial switch game.state {
|
||||||
|
case .IN_GAME: update_gameplay(dt, game)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game_render :: proc(game: ^Game) {
|
game_render :: proc(game: ^Game) {
|
||||||
rl.BeginDrawing()
|
rl.BeginDrawing()
|
||||||
rl.ClearBackground(rl.DARKGRAY)
|
rl.ClearBackground(rl.DARKGRAY)
|
||||||
|
|
||||||
|
#partial switch game.state {
|
||||||
|
case .IN_GAME: render_gameplay(game)
|
||||||
|
}
|
||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
game_quit :: proc(game: ^Game) {
|
game_quit :: proc(game: ^Game) {
|
||||||
rl.CloseWindow()
|
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
@@ -19,15 +19,17 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|
||||||
|
// Game Start
|
||||||
game := Game{}
|
game := Game{}
|
||||||
|
|
||||||
game_init(&game)
|
game_init(&game)
|
||||||
|
|
||||||
|
// Game loop
|
||||||
for game_should_run() {
|
for game_should_run() {
|
||||||
game_update(&game)
|
game_update(&game)
|
||||||
game_render(&game)
|
game_render(&game)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Game Stop
|
||||||
game_quit(&game)
|
game_quit(&game)
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user