Class: BTetrisKp::BTetrisWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- BTetrisKp::BTetrisWindow
- Defined in:
- lib/btetris_kp/btetris.rb
Overview
Main class maintaining game window, drawing, updating and reacting to key events
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#button_down(id) ⇒ Object
propagates button_down event to current window state.
-
#draw ⇒ Object
propagates draw event to current window state.
-
#initialize ⇒ BTetrisWindow
constructor
A new instance of BTetrisWindow.
-
#needs_cursor? ⇒ Boolean
shows or hides default system cursor depending on state.
-
#update ⇒ Object
propagates update event to current window state.
Constructor Details
#initialize ⇒ BTetrisWindow
Returns a new instance of BTetrisWindow.
11 12 13 14 15 |
# File 'lib/btetris_kp/btetris.rb', line 11 def initialize super(Const::GAME_WIDTH, Const::GAME_HEIGHT, false) self. = Const::GAME_CAPTION @state = MenuState.new(self) end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
9 10 11 |
# File 'lib/btetris_kp/btetris.rb', line 9 def state @state end |
Instance Method Details
#button_down(id) ⇒ Object
propagates button_down event to current window state
28 29 30 |
# File 'lib/btetris_kp/btetris.rb', line 28 def (id) @state.(id) end |
#draw ⇒ Object
propagates draw event to current window state
23 24 25 |
# File 'lib/btetris_kp/btetris.rb', line 23 def draw @state.draw end |
#needs_cursor? ⇒ Boolean
shows or hides default system cursor depending on state
33 34 35 |
# File 'lib/btetris_kp/btetris.rb', line 33 def needs_cursor? @state.needs_cursor? end |
#update ⇒ Object
propagates update event to current window state
18 19 20 |
# File 'lib/btetris_kp/btetris.rb', line 18 def update @state.update end |