Refactor debug checks to use event bus settings for consistency across game components.

This commit is contained in:
2026-03-28 23:24:09 +00:00
parent 1fbd12e6f6
commit 3dbeadf976
9 changed files with 30 additions and 13 deletions
+2 -2
View File
@@ -114,7 +114,7 @@ class Character
end
# teleport to boss room for debug purposes
if DEBUG && Gosu.button_down?(Gosu::KB_T)
if $bus.get(:settings, :debug) && Gosu.button_down?(Gosu::KB_T)
room_coords = $bus.get(:boss_room_coords)
if room_coords
@world_x, @world_y = [room_coords[0] * 60 + 5, room_coords[1] * 60 + 5]
@@ -138,7 +138,7 @@ class Character
frame_index = ((elapsed * 7).floor) % 6
@animations[@current_animation][frame_index].draw(sprite_x, sprite_y, sprite_y + 30, 1.8, 1.8)
return unless DEBUG
return unless $bus.get(:settings, :debug)
Gosu.draw_rect(cx, cy, SIZE[0], SIZE[1], Gosu::Color.new(0x8000FF00), cy)
end
+1 -1
View File
@@ -76,7 +76,7 @@ class EnemyAI
end
def draw
return unless DEBUG
return unless $bus.get(:settings, :debug)
cam_x, cam_y = $bus.get(:camera_pos) || [0, 0]
@waypoints.each do |wx, wy|
Gosu.draw_rect(wx - cam_x - 5, wy - cam_y - 5, 10, 10, Gosu::Color.new(0x88ffff00), Float::INFINITY)
+1 -1
View File
@@ -130,7 +130,7 @@ class Inventory
if id == Gosu::MS_LEFT
@inventory_selected = type
elsif id == Gosu::MS_RIGHT
if DEBUG && [:wood, :metal, :science].include?(type)
if $bus.get(:settings, :debug) && [:wood, :metal, :science].include?(type)
@grid[row_idx][col_idx][1][0] = max
else
craft(type, ctrl: Gosu.button_down?(Gosu::KB_RIGHT_CONTROL) || Gosu.button_down?(Gosu::KB_LEFT_CONTROL))
+1 -1
View File
@@ -103,7 +103,7 @@ class Maze
@spritesheet[index - 1].draw(screen_x, screen_y, screen_y, scale, scale)
next unless DEBUG
next unless $bus.get(:settings, :debug)
shapes = shapes_for(index, gx * tile_size, gy * tile_size)
shapes.each do |shape|
+1 -1
View File
@@ -100,7 +100,7 @@ class Prop
Gosu.draw_rect(bar_x, bar_y, bar_width, bar_height, Gosu::Color::RED, screen_y - 19)
end
return unless DEBUG
return unless $bus.get(:settings, :debug)
# collision box centered on same point
Gosu.draw_rect(screen_x - SIZE[0] / 2, screen_y - SIZE[1], *SIZE, Gosu::Color.new(0x88ff0000), Float::INFINITY)
+2 -2
View File
@@ -38,8 +38,8 @@ class Game < Scene
@enemies.draw
@props.draw
@hud.draw
draw_fog!
draw_debug! if DEBUG
draw_fog! if $bus.get(:settings, :fog)
draw_debug! if $bus.get(:settings, :debug)
end
def draw_debug!