package game import rl "vendor:raylib" Debug :: struct { active: bool, bounds_active: bool, camera_active: bool, camera: rl.Camera2D, } debug_init :: proc(game: ^Game) { when DEBUG_MODE { game.debug.active = true game.debug.camera_active = false game.debug.camera = debug_camera_init(game.player) log_info("!! Debug Mode Enabled") } } debug_fps :: proc() { when DEBUG_MODE { rl.DrawFPS(20, 20) } } // DEBUG CAMERA debug_camera_init :: proc(player: Player) -> rl.Camera2D { when !DEBUG_MODE { return rl.Camera2D{} } when DEBUG_MODE { offset_adjust := (TILE_SIZE / 2) * 0.3 return rl.Camera2D { target = player.position, offset = rl.Vector2{ f32(GAME_WIDTH/2 - offset_adjust), f32(GAME_HEIGHT/2 - offset_adjust) }, rotation = 0, zoom = 0.3 } } } debug_camera_update :: proc(debug: ^Debug) { when DEBUG_MODE { if rl.IsKeyPressed(.ONE) { debug.camera_active = !debug.camera_active } if rl.IsKeyPressed(.TWO) { debug.bounds_active = !debug.bounds_active } if rl.IsKeyDown(.LEFT_CONTROL) { scroll := rl.GetMouseWheelMove() if scroll != 0.0 { debug.camera.zoom += scroll * 0.1 } } } } debug_camera_draw :: proc(camera: ^rl.Camera2D, active: bool) { when DEBUG_MODE { if active { view_width := GAME_WIDTH / camera.zoom view_height := GAME_HEIGHT / camera.zoom top_left := camera.target - rl.Vector2{ f32(view_width)/2, f32(view_height)/2 } rl.DrawRectangleLines(i32(top_left.x), i32(top_left.y), i32(view_width), i32(view_height), rl.RED) } } } // Collision stuff debug_bounds :: proc(game: ^Game) { when DEBUG_MODE { if game.debug.bounds_active { // player player := game.player player_collider := get_player_collider(&game.player, game.player.position) rl.DrawRectangleLines( i32(player.position.x), i32(player.position.y), TILE_SIZE, TILE_SIZE, rl.GREEN) rl.DrawRectangleLinesEx(player_collider, 1, rl.BLUE) } } }