Implement enemy pathfinding restrictions in starting room; rectify collision rectangle checks for props; create new trap and weapon files.

This commit is contained in:
2026-03-29 13:42:59 +00:00
parent 5d16a15a41
commit 5f3b6b8e29
11 changed files with 26 additions and 3 deletions
+7
View File
@@ -19,6 +19,13 @@ class EnemyAI
player_tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round) player_tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round)
enemy_tile = [(@enemy.x - 90) / 120, (@enemy.y - 90) / 120].map(&:round) enemy_tile = [(@enemy.x - 90) / 120, (@enemy.y - 90) / 120].map(&:round)
# Don't pathfind if both player and enemy are in the starting room to make sure the player has a safe space to learn the mechanics.
start_room_tile = ($bus.get(:start_room_coords) || [0, 0])
return if player_tile[0] > start_room_tile[0] - 1 && player_tile[0] < start_room_tile[0] + 3 &&
player_tile[1] > start_room_tile[1] - 1 && player_tile[1] < start_room_tile[1] + 3 &&
enemy_tile[0] > start_room_tile[0] - 1 && enemy_tile[0] < start_room_tile[0] + 3 &&
enemy_tile[1] > start_room_tile[1] - 1 && enemy_tile[1] < start_room_tile[1] + 3
return if $bus.get_all(:collides?, @enemy.rect)&.include?(:character) return if $bus.get_all(:collides?, @enemy.rect)&.include?(:character)
prop_in_tile = $bus.get(:prop_at, enemy_tile[0], enemy_tile[1]) prop_in_tile = $bus.get(:prop_at, enemy_tile[0], enemy_tile[1])
+3 -3
View File
@@ -101,7 +101,7 @@ class PropsHandler
tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round) tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round)
torch = Torch.new(*tile) torch = Torch.new(*tile)
return if @grid[[tile[0], tile[1]]] # can't place if something is already there return if @grid[[tile[0], tile[1]]] # can't place if something is already there
return if $bus.get_all(:collides?, torch.rect).include?(:character) # can't place if colliding with player return if $bus.get_all(:collides?, torch.collision_rect).include?(:character) # can't place if colliding with player
return unless $bus.get(:consume, :torch, 1) return unless $bus.get(:consume, :torch, 1)
add(torch) add(torch)
elsif selected_item == :radar elsif selected_item == :radar
@@ -109,7 +109,7 @@ class PropsHandler
tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round) tile = [(player_x - 90) / 120, (player_y - 90) / 120].map(&:round)
radar = Radar.new(*tile) radar = Radar.new(*tile)
return if @grid[[tile[0], tile[1]]] return if @grid[[tile[0], tile[1]]]
return if $bus.get_all(:collides?, radar.rect).include?(:character) return if $bus.get_all(:collides?, radar.collision_rect).include?(:character)
return unless $bus.get(:consume, :radar, 1) return unless $bus.get(:consume, :radar, 1)
add(radar) add(radar)
end end
@@ -141,7 +141,7 @@ class PropsHandler
world_y = y * 120 + 90 world_y = y * 120 + 90
screen_x = world_x - cam_x screen_x = world_x - cam_x
screen_y = world_y - cam_y screen_y = world_y - cam_y
possible = !$bus.get_all(:collides?, [world_x - 20, world_y - 20, 40, 40]).include?(:character) possible = !$bus.get_all(:collides?, [world_x - Prop::SIZE[0] / 2, world_y - Prop::SIZE[1], *Prop::SIZE]).include?(:character)
color = possible ? Gosu::Color.new(255 * 0.7, 128, 239, 128) : Gosu::Color.new(255 * 0.7, 255, 116, 108) color = possible ? Gosu::Color.new(255 * 0.7, 128, 239, 128) : Gosu::Color.new(255 * 0.7, 255, 116, 108)
if selected_item == :torch if selected_item == :torch
Torch.ghost.draw(screen_x - 20, screen_y - 20, screen_y, 2, 2, color) Torch.ghost.draw(screen_x - 20, screen_y - 20, screen_y, 2, 2, color)
View File
View File
View File
View File
View File
View File
+16
View File
@@ -0,0 +1,16 @@
class LorentzField < Weapon
def initialize
super(
name: "Lorentz Field",
description: "A defensive weapon that creates a time distortion field around the user. While active, the field slows down incoming projectiles and enemies, giving the user a chance to react and evade. The field lasts for a short duration and has a cooldown period before it can be used again.",
image_path: "assets/images/lorentz_field.png",
cooldown: 5.0,
damage: 0,
range: 0,
area_of_effect: 0
)
end
def activate(user)
end
end
View File
View File