Class: GameOver
- Inherits:
-
Chingu::GameState
- Object
- Chingu::GameState
- GameOver
- Defined in:
- lib/prkwars/gameover.rb
Overview
Class representing the game over state shown when the player loses the game.
Instance Method Summary collapse
-
#initialize(score, options = {}) ⇒ GameOver
constructor
Initialization of the game over screen does nothing else but map inputs to the
playmethod (in case the player wishes to play again) and draws text on the screen. -
#play ⇒ Object
Switches the game state.
Constructor Details
#initialize(score, options = {}) ⇒ GameOver
Initialization of the game over screen does nothing else but map inputs to the play method (in case the player wishes to play again) and draws text on the screen.
12 13 14 15 16 17 18 19 20 |
# File 'lib/prkwars/gameover.rb', line 12 def initialize(score, = {}) super() self.input = { space: :play, esc: :exit } Chingu::Text.create("Final score: #{score}", x: 20, y: 20, size: 30) Chingu::Text.create('Press <space> to play again, <esc> to exit.', x: 20, y: 60) end |
Instance Method Details
#play ⇒ Object
Switches the game state. Calls Play.new instead of just Play in order to call the initialize method instead of the setup method.
25 26 27 |
# File 'lib/prkwars/gameover.rb', line 25 def play switch_game_state(Play.new) end |