diff options
| author | iamcheeseman <[hidden email]> | 2026-01-15 13:51:07 -0500 |
|---|---|---|
| committer | iamcheeseman <[hidden email]> | 2026-01-15 13:51:07 -0500 |
| commit | 4563dfa077e029fbefd192f087338d186155ebfc (patch) | |
| tree | 4af1101f408081e74fc12cb372824b7e2d3e70d4 /src/main.odin | |
| parent | 3c640e0d8244f87fec9518a60c7e5e95713d7f78 (diff) | |
Debug mode; displays collision shapes
Diffstat (limited to 'src/main.odin')
| -rw-r--r-- | src/main.odin | 22 |
1 files changed, 21 insertions, 1 deletions
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() } |
