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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/empi.rb', line 18 def initialize(width = (MAPX + 1) * TILESIZE, \ height = (MAPY + 2) * TILESIZE, \ fullscreen = false) super # Set version name version = '0.25' self.caption = "Empi: Ruby Edition #{version}" WelcomeState.instance.version = version # 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
34 35 36 |
# File 'lib/empi.rb', line 34 def (key) = key end |
#draw ⇒ Object
Draw according to current state
52 53 54 55 56 57 |
# File 'lib/empi.rb', line 52 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
47 48 49 |
# File 'lib/empi.rb', line 47 def needs_redraw? != BUTTON_PROCESSED end |
#update ⇒ Object
Process given button according to current state
39 40 41 42 43 44 |
# File 'lib/empi.rb', line 39 def update # No (new) keys unless == BUTTON_PROCESSED || .nil? @state.update() end end |