Class: GameScene
Constant Summary collapse
- WIDTH =
10
- HEIGHT =
20
- BLOCK_SIZE =
pixels
20
Instance Attribute Summary
Attributes inherited from Scene
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
- #game_running? ⇒ Boolean
-
#initialize(window, difficulty) ⇒ GameScene
constructor
A new instance of GameScene.
- #update ⇒ Object
Constructor Details
Instance Method Details
#button_down(id) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/scene.rb', line 121 def (id) case id when Gosu::KB_ESCAPE @window. when Gosu::KB_LEFT @game.move(-1, 0) when Gosu::KB_RIGHT @game.move(1, 0) when Gosu::KB_UP @game.rotate when Gosu::KB_DOWN @game.move(0, 1) when Gosu::KB_SPACE @game.fast_move end end |
#draw ⇒ Object
143 144 145 146 147 |
# File 'lib/scene.rb', line 143 def draw @window.font.draw_text("Score: #{@game.score}", 10, 10, ZOrder::UI, 1.0, 1.0, Gosu::Color::YELLOW) @window.font.draw_text("Speed: #{@game.current_difficulty}", 250, 10, ZOrder::UI, 1.0, 1.0, Gosu::Color::YELLOW) @game.draw(@window) end |
#game_running? ⇒ Boolean
139 140 141 |
# File 'lib/scene.rb', line 139 def game_running? !@game.game_over end |
#update ⇒ Object
117 118 119 |
# File 'lib/scene.rb', line 117 def update @game.update end |