Enhance game over scene: implement GameOver class with options for retry and main menu, add background image, and handle mouse and keyboard interactions.

This commit is contained in:
2026-04-02 15:33:50 +01:00
parent 32de437f86
commit db7c2aa7a2
12 changed files with 100 additions and 28 deletions
+8 -3
View File
@@ -12,7 +12,7 @@ class EventBus
end
# Subscribe to an event
def on(event, owner: nil, &callback)
def on(event, owner = nil, &callback)
owner ||= callback.binding.eval("self")
@events[event] << { callback: callback, owner: owner }
end
@@ -51,9 +51,14 @@ class EventBus
results
end
# Unsubscribe all events for a given owner (e.g. when an object is destroyed)
def reset
@events.each do |_, handlers|
handlers.reject! { |h| h[:owner] != :master }
end
end
def remove_owner(owner)
@events.each do |event, handlers|
@events.each do |_, handlers|
handlers.reject! { |h| h[:owner] == owner }
end
end
-4
View File
@@ -12,8 +12,4 @@ class Scene
def button_down(id, pos)
end
def close
$bus.remove_owner(self)
end
end