From 4563dfa077e029fbefd192f087338d186155ebfc Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Thu, 15 Jan 2026 13:51:07 -0500 Subject: Debug mode; displays collision shapes --- src/main.odin | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/main.odin') diff --git a/src/main.odin b/src/main.odin index 1e3f8ba..969c25b 100644 --- a/src/main.odin +++ b/src/main.odin @@ -21,6 +21,7 @@ Rect :: struct { } state: struct { + debug_mode: bool, camera: rl.Camera2D, platform_list: Entity_List(Platform), bullet_list: Entity_List(Bullet), @@ -65,6 +66,10 @@ init :: proc() { } frame :: proc() { + if is_keybind_just_down(actions.toggle_debug_mode) { + state.debug_mode = !state.debug_mode + } + update_player(rl.GetFrameTime()) update_bullets(rl.GetFrameTime()) @@ -75,7 +80,18 @@ frame :: proc() { draw_player() draw_room(current_room.id) draw_bullets() - // draw_platforms() + + if state.debug_mode { + // Draw all collisions + body_it: int + renderer.tint = {1, 0.25, 0.5, 0.5} + for body in phys.iterate_bodies(&body_it) { + rect := phys.get_rect(body) + rect.start += phys.get_position(body) + draw_linerect(transmute(Rect)rect) + } + renderer.tint = {1, 1, 1, 1} + } rl.EndMode2D() @@ -86,6 +102,10 @@ frame :: proc() { ) rl.DrawText(fps_text, 5, 5, 8, rl.GREEN) + if state.debug_mode { + rl.DrawText("Debug Mode", 5, 5 + 8, 8, rl.YELLOW) + } + draw_end_frame() } -- cgit v1.3-2-g0d8e