Initial map interface.
This commit is contained in:
+11
-8
@@ -6,6 +6,7 @@ Game :: struct {
|
||||
assets: Asset_Manager,
|
||||
camera: rl.Camera2D,
|
||||
world: rl.RenderTexture2D,
|
||||
current_map: Game_Map,
|
||||
player: Player,
|
||||
debug: Debug
|
||||
}
|
||||
@@ -20,6 +21,7 @@ game_init :: proc() -> Game {
|
||||
game.player = player_init(&game.assets.player)
|
||||
game.camera = camera_init(game.player, 1)
|
||||
game.world = rl.LoadRenderTexture(GAME_WIDTH, GAME_HEIGHT)
|
||||
game.current_map = map_init()
|
||||
|
||||
// DEBUG
|
||||
debug_init(&game)
|
||||
@@ -32,25 +34,26 @@ game_should_run :: proc(game: ^Game) -> bool {
|
||||
}
|
||||
|
||||
game_update :: proc(game: ^Game) {
|
||||
update_player(&game.player, &game.assets.player)
|
||||
update_player(&game.player, &game.assets.player, game.camera)
|
||||
update_camera(game.player.pos, &game.camera)
|
||||
|
||||
// DEBUG
|
||||
// DEBUG
|
||||
debug_camera_update(&game.debug)
|
||||
}
|
||||
|
||||
game_draw :: proc(game: ^Game) {
|
||||
cam := game.camera
|
||||
if game.debug.camera_active {
|
||||
cam = game.debug.camera
|
||||
cam = game.debug.camera
|
||||
}
|
||||
|
||||
rl.BeginTextureMode(game.world)
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
rl.BeginMode2D(cam)
|
||||
renderer_draw_player(&game.player)
|
||||
draw_map(game.current_map)
|
||||
draw_player(&game.player)
|
||||
|
||||
// DEBUG
|
||||
// DEBUG
|
||||
debug_camera_draw(&game.camera, game.debug.camera_active)
|
||||
debug_bounds(game)
|
||||
rl.EndMode2D()
|
||||
@@ -65,7 +68,7 @@ game_draw :: proc(game: ^Game) {
|
||||
x = 0, y = 0,
|
||||
width = f32(game.world.texture.width),
|
||||
// raylib opengl negative to flip Y?
|
||||
height = -f32(game.world.texture.height),
|
||||
height = -f32(game.world.texture.height),
|
||||
},
|
||||
rl.Rectangle{
|
||||
x = 0, y = 0,
|
||||
@@ -77,7 +80,7 @@ game_draw :: proc(game: ^Game) {
|
||||
rl.WHITE,
|
||||
)
|
||||
|
||||
// DEBUG
|
||||
// DEBUG
|
||||
debug_fps()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
@@ -86,4 +89,4 @@ game_close :: proc(game: ^Game) {
|
||||
asset_manager_destroy(&game.assets)
|
||||
rl.UnloadRenderTexture(game.world)
|
||||
rl.CloseWindow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user