Add debug teleportation and player position display; enhance maze debug output
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class Character
|
||||
attr_reader :world_x, :world_y
|
||||
|
||||
SPEED = 2.5
|
||||
SIZE = [25, 30]
|
||||
|
||||
@@ -89,6 +91,14 @@ class Character
|
||||
@world_y -= dy
|
||||
end
|
||||
|
||||
# teleport to boss room for debug purposes
|
||||
if 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]
|
||||
end
|
||||
end
|
||||
|
||||
# Camera follow
|
||||
cam_x = @world_x - SCREEN_SIZE[0] / 2.0
|
||||
cam_y = @world_y - SCREEN_SIZE[1] / 2.0
|
||||
|
||||
+5
-6
@@ -51,13 +51,14 @@ class Game < Scene
|
||||
end
|
||||
|
||||
@font.draw_text("FPS: #{@fps}", 5, 5, Float::INFINITY, 1, 1, Gosu::Color::YELLOW)
|
||||
@font.draw_text("Player: [#{@character.world_x.round}, #{@character.world_y.round}]", 5, 30, Float::INFINITY, 1, 1, Gosu::Color::YELLOW)
|
||||
end
|
||||
|
||||
def draw_fog(camera)
|
||||
cam_x, cam_y = camera
|
||||
cell = 10
|
||||
i_radius = 80.0
|
||||
o_radius = 360.0
|
||||
i_radius = 90.0
|
||||
o_radius = 400.0
|
||||
|
||||
# Player screen position
|
||||
px = SCREEN_SIZE[0] / 2.0
|
||||
@@ -71,20 +72,18 @@ class Game < Scene
|
||||
sx = i * cell
|
||||
sy = j * cell
|
||||
|
||||
|
||||
dist = Math.sqrt((sx - px)**2 + (sy - py)**2)
|
||||
|
||||
|
||||
if dist < i_radius
|
||||
next # fully clear
|
||||
elsif dist > o_radius
|
||||
alpha = 255
|
||||
else
|
||||
t = (dist - i_radius) / (o_radius - i_radius) # 0..1
|
||||
|
||||
world_x = (sx + cam_x) * 0.005
|
||||
world_y = (sy + cam_y) * 0.005
|
||||
|
||||
# Sample noise at world position so it scrolls with camera
|
||||
# Add time-based offsets for animation
|
||||
noise = (@noise[world_x + Gosu.milliseconds / 5000.0, world_y + Gosu.milliseconds / 6000.0] + 1.0) / 2.0
|
||||
alpha = (t * (1.0 + noise) * 255).to_i.clamp(0, 255)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user