Refactor event bus to use non-retrievable events;

update collision handling and add new inventory initialization;
add torch lighting in fog shader;
This commit is contained in:
2026-03-28 11:38:20 +00:00
parent 15c457e7a6
commit bf93aecad1
14 changed files with 150 additions and 60 deletions
+7 -3
View File
@@ -37,9 +37,13 @@ class Character
@current_animation = :idle_front
@facing = :front
$bus.on_retrievable(:player_position) do
$bus.on(:player_position) do
next [@world_x, @world_y]
end
$bus.on(:collides?) do |rect|
next collides?(rect) ? :character : nil
end
end
def rect
@@ -95,13 +99,13 @@ class Character
steps.times do
# X axis
@world_x += step_dx
if ($bus.get(:collides?, rect) & [:wall, :object])&.any?
if ($bus.get_all(:collides?, rect) & [:wall, :object])&.any?
@world_x -= step_dx
end
# Y axis
@world_y += step_dy
if ($bus.get(:collides?, rect) & [:wall, :object])&.any?
if ($bus.get_all(:collides?, rect) & [:wall, :object])&.any?
@world_y -= step_dy
end
end