Class: GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- GameWindow
- Defined in:
- lib/empi.rb
Overview
Main class
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#button_up(key) ⇒ Object
Catch the released button.
-
#draw ⇒ Object
Draw according to current state.
-
#initialize(width = (MAPX + 1) * TILESIZE, height = (MAPY + 2) * TILESIZE, fullscreen = false) ⇒ GameWindow
constructor
A new instance of GameWindow.
-
#needs_redraw? ⇒ Boolean
Draw only after some button was released and in the start.
-
#update ⇒ Object
Process given button according to current state.
Constructor Details
#initialize(width = (MAPX + 1) * TILESIZE, height = (MAPY + 2) * TILESIZE, fullscreen = false) ⇒ GameWindow
Returns a new instance of GameWindow.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/empi.rb', line 18 def initialize(width = (MAPX + 1) * TILESIZE, \ height = (MAPY + 2) * TILESIZE, \ fullscreen = false) super self.caption = 'Empi: Ruby Edition 0.24' # Activate first state $window = self GameState.switch!(WelcomeState.instance) end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
16 17 18 |
# File 'lib/empi.rb', line 16 def state @state end |
Instance Method Details
#button_up(key) ⇒ Object
Catch the released button
30 31 32 |
# File 'lib/empi.rb', line 30 def (key) = key end |
#draw ⇒ Object
Draw according to current state
48 49 50 51 52 53 54 |
# File 'lib/empi.rb', line 48 def draw = BUTTON_PROCESSED # draw just once after each button release unless $window.state.nil? @state.draw end end |
#needs_redraw? ⇒ Boolean
Draw only after some button was released and in the start
43 44 45 |
# File 'lib/empi.rb', line 43 def needs_redraw? != BUTTON_PROCESSED end |
#update ⇒ Object
Process given button according to current state
35 36 37 38 39 40 |
# File 'lib/empi.rb', line 35 def update # No (new) keys unless == BUTTON_PROCESSED || .nil? @state.update() end end |