Add new assets and implement minimap functionality

- Added new image assets for game over screens: `game_over_dead_bg.png`, `game_over_victory_bg.png`, and their respective Aseprite files.
- Introduced a new `Minimap` class to manage torch placement and rendering on the minimap.
- Implemented methods for adding and removing torches, updating the grid area, and drawing the minimap based on the current state of the game.
- Enhanced the minimap display with color coding for walls, empty spaces, and torches.
This commit is contained in:
2026-04-03 02:51:11 +01:00
parent b325b35c88
commit 222b28d196
24 changed files with 209 additions and 32 deletions
+17
View File
@@ -1,6 +1,7 @@
require_relative "inventory"
require_relative "health"
require_relative "logs"
require_relative "minimap"
class HUDLayer
def initialize
@@ -9,6 +10,9 @@ class HUDLayer
@inventory = Inventory.new
@health = HealthBar.new(100)
@logs = GameLogger.new
@minimap = Minimap.new
@direction_sprite = Gosu::Image.new("assets/images/direction.png", retro: true)
$bus.on(:enemy_attack) do |damage|
@health.take_damage(damage)
@@ -26,6 +30,19 @@ class HUDLayer
@health.draw
@logs.draw
player_x, player_y = $bus.get(:player_position) || [0, 0]
tile_x = ((player_x - 90) / 120).round
tile_y = ((player_y - 90) / 120).round
center_x = tile_x * 2 + 1
center_y = tile_y * 2 + 1
@minimap.draw(center_x, center_y)
if $bus.get(:radar_triangulation?, player_x, player_y)
exit_x, exit_y = $bus.get(:exit_room_coords) || [0, 0]
angle_to_exit = Math.atan2(exit_y - tile_x, exit_x - tile_y) * 180 / Math::PI
@direction_sprite.draw_rot(SCREEN_SIZE[0] / 2, SCREEN_SIZE[1] / 2, Float::INFINITY, angle_to_exit, 0.5, 0.5, 5, 5)
end
@hud_fg.draw(0, 0, Float::INFINITY)
end