Class: CyberarmEngine::GameState
- Inherits:
-
Object
- Object
- CyberarmEngine::GameState
- Includes:
- Common
- Defined in:
- lib/cyberarm_engine/game_state.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#game_objects ⇒ Object
readonly
Returns the value of attribute game_objects.
-
#global_pause ⇒ Object
Returns the value of attribute global_pause.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #add_game_object(object) ⇒ Object
- #button_down(id) ⇒ Object
- #button_up(id) ⇒ Object
- #destroy ⇒ Object
- #draw ⇒ Object
- #draw_bounding_box(box) ⇒ Object
-
#initialize(options = {}) ⇒ GameState
constructor
A new instance of GameState.
-
#post_setup ⇒ Object
Called immediately after setup returns.
- #setup ⇒ Object
- #update ⇒ Object
Methods included from Common
#current_state, #darken, #draw_rect, #fill, #get_asset, #get_image, #get_sample, #get_song, #lighten, #opacity, #pop_state, #previous_state, #push_state, #shift_state, #show_cursor, #show_cursor=, #window
Constructor Details
#initialize(options = {}) ⇒ GameState
Returns a new instance of GameState.
8 9 10 11 12 13 14 15 |
# File 'lib/cyberarm_engine/game_state.rb', line 8 def initialize( = {}) @options = @game_objects = [] @global_pause = false $window.text_input = nil unless [:preserve_text_input] @down_keys = {} end |
Instance Attribute Details
#game_objects ⇒ Object (readonly)
Returns the value of attribute game_objects.
6 7 8 |
# File 'lib/cyberarm_engine/game_state.rb', line 6 def game_objects @game_objects end |
#global_pause ⇒ Object
Returns the value of attribute global_pause.
5 6 7 |
# File 'lib/cyberarm_engine/game_state.rb', line 5 def global_pause @global_pause end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/cyberarm_engine/game_state.rb', line 5 def @options end |
Instance Method Details
#add_game_object(object) ⇒ Object
93 94 95 |
# File 'lib/cyberarm_engine/game_state.rb', line 93 def add_game_object(object) @game_objects << object end |
#button_down(id) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/cyberarm_engine/game_state.rb', line 77 def (id) @down_keys[id] = true @game_objects.each do |o| o.(id) end end |
#button_up(id) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/cyberarm_engine/game_state.rb', line 85 def (id) @down_keys.delete(id) @game_objects.each do |o| o.(id) end end |
#destroy ⇒ Object
72 73 74 75 |
# File 'lib/cyberarm_engine/game_state.rb', line 72 def destroy @options.clear @game_objects.clear end |
#draw ⇒ Object
25 26 27 |
# File 'lib/cyberarm_engine/game_state.rb', line 25 def draw @game_objects.each(&:draw) end |
#draw_bounding_box(box) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cyberarm_engine/game_state.rb', line 33 def draw_bounding_box(box) x = box.x y = box.y max_x = box.max_x max_y = box.max_y color = Gosu::Color.rgba(255, 127, 64, 240) # pipe = 4 # Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY) # puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}" # Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY) # TOP LEFT to BOTTOM LEFT $window.draw_line( x, y, color, x, max_y, color, Float::INFINITY ) # BOTTOM LEFT to BOTTOM RIGHT $window.draw_line( x, max_y, color, max_x, max_y, color, Float::INFINITY ) # BOTTOM RIGHT to TOP RIGHT $window.draw_line( max_x, max_y, color, max_x, y, color, Float::INFINITY ) # TOP RIGHT to TOP LEFT $window.draw_line( max_x, y, color, x, y, color, Float::INFINITY ) end |
#post_setup ⇒ Object
Called immediately after setup returns. GuiState uses this to set current_theme for ToolTip
22 23 |
# File 'lib/cyberarm_engine/game_state.rb', line 22 def post_setup end |
#setup ⇒ Object
17 18 |
# File 'lib/cyberarm_engine/game_state.rb', line 17 def setup end |
#update ⇒ Object
29 30 31 |
# File 'lib/cyberarm_engine/game_state.rb', line 29 def update @game_objects.each(&:update) end |