Refactored Container to be an Element, removed button_up/button_down passing to elements, moved Gui out of GameState and into GuiState, added scaffolding for events (Publish/Subscribe pattern). Element input is broken ATM.

This commit is contained in:
2019-03-01 09:41:51 -06:00
parent 04ec6682ee
commit 18ff0a1ea9
15 changed files with 258 additions and 234 deletions

View File

@@ -1,7 +1,6 @@
module CyberarmEngine
class GameState
include Common
include DSL
attr_accessor :options, :global_pause
attr_reader :game_objects, :containers
@@ -11,10 +10,6 @@ module CyberarmEngine
@game_objects = []
@global_pause = false
@root_container = Stack.new(x: 0, y: 0, width: $window.width, height: $window.height)
@game_objects << @root_container
@containers = [@root_container]
setup
end
@@ -34,6 +29,12 @@ module CyberarmEngine
@game_objects = nil
end
def down_up(id)
@game_objects.each do |o|
o.button_down(id)
end
end
def button_up(id)
@game_objects.each do |o|
o.button_up(id)