Class: GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- GameWindow
- Defined in:
- lib/misc/game_window.rb
Overview
class GameWindow
Instance Attribute Summary collapse
-
#mediamanager ⇒ Object
Returns the value of attribute mediamanager.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ GameWindow
constructor
A new instance of GameWindow.
- #keymap ⇒ Object
- #needs_redraw? ⇒ Boolean
- #update ⇒ Object
Constructor Details
#initialize ⇒ GameWindow
Returns a new instance of GameWindow.
8 9 10 11 12 13 |
# File 'lib/misc/game_window.rb', line 8 def initialize super(256, 224, true) self.caption = 'Battle city' @unitsize = 8 @mediamanager = MediaManager.new(self) end |
Instance Attribute Details
#mediamanager ⇒ Object
Returns the value of attribute mediamanager.
7 8 9 |
# File 'lib/misc/game_window.rb', line 7 def mediamanager @mediamanager end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/misc/game_window.rb', line 6 def state @state end |
Instance Method Details
#button_down(id) ⇒ Object
27 28 29 |
# File 'lib/misc/game_window.rb', line 27 def (id) @state.(id) end |
#draw ⇒ Object
19 20 21 |
# File 'lib/misc/game_window.rb', line 19 def draw @state.draw end |
#keymap ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/misc/game_window.rb', line 31 def keymap keys = [] keys.push(:p1up) if Gosu::(Gosu::KbUp) keys.push(:p1down) if Gosu::(Gosu::KbDown) keys.push(:p1left) if Gosu::(Gosu::KbLeft) keys.push(:p1right) if Gosu::(Gosu::KbRight) keys.push(:p2up) if Gosu::(Gosu::KbW) keys.push(:p2down) if Gosu::(Gosu::KbS) keys.push(:p2left) if Gosu::(Gosu::KbA) keys.push(:p2right) if Gosu::(Gosu::KbD) keys.push(:p1shoot) if Gosu::(Gosu::KbRightControl) keys.push(:p2shoot) if Gosu::(Gosu::KbLeftControl) keys end |
#needs_redraw? ⇒ Boolean
23 24 25 |
# File 'lib/misc/game_window.rb', line 23 def needs_redraw? @state.needs_redraw? end |
#update ⇒ Object
15 16 17 |
# File 'lib/misc/game_window.rb', line 15 def update @state.update(keymap) end |