Added debug funcs and struct to game
This commit is contained in:
+19
-5
@@ -6,7 +6,8 @@ Game :: struct {
|
||||
assets: Asset_Manager,
|
||||
camera: rl.Camera2D,
|
||||
world: rl.RenderTexture2D,
|
||||
player: Player
|
||||
player: Player,
|
||||
debug: Debug
|
||||
}
|
||||
|
||||
game_init :: proc() -> Game {
|
||||
@@ -20,6 +21,9 @@ game_init :: proc() -> Game {
|
||||
game.camera = camera_init(game.player, 1)
|
||||
game.world = rl.LoadRenderTexture(GAME_WIDTH, GAME_HEIGHT)
|
||||
|
||||
// DEBUG
|
||||
debug_init(&game)
|
||||
|
||||
return game
|
||||
}
|
||||
|
||||
@@ -30,14 +34,25 @@ game_should_run :: proc(game: ^Game) -> bool {
|
||||
game_update :: proc(game: ^Game) {
|
||||
update_player(&game.player, &game.assets.player)
|
||||
update_camera(game.player.pos, &game.camera)
|
||||
|
||||
// DEBUG
|
||||
debug_camera_update(&game.debug)
|
||||
}
|
||||
|
||||
game_draw :: proc(game: ^Game) {
|
||||
cam := game.camera
|
||||
if game.debug.camera_active {
|
||||
cam = game.debug.camera
|
||||
}
|
||||
|
||||
rl.BeginTextureMode(game.world)
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
rl.BeginMode2D(game.camera)
|
||||
draw_camera(&game.camera)
|
||||
rl.BeginMode2D(cam)
|
||||
renderer_draw_player(&game.player)
|
||||
|
||||
// DEBUG
|
||||
debug_camera_draw(&game.camera, game.debug.camera_active)
|
||||
debug_bounds(game)
|
||||
rl.EndMode2D()
|
||||
rl.EndTextureMode()
|
||||
|
||||
@@ -62,8 +77,7 @@ game_draw :: proc(game: ^Game) {
|
||||
rl.WHITE,
|
||||
)
|
||||
|
||||
// Debug functions
|
||||
// ---------
|
||||
// DEBUG
|
||||
debug_fps()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user