class GameOver
Class representing the game over state shown when the player loses the game.
Public Class Methods
new(score, options = {})
click to toggle source
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.
Calls superclass method
# File lib/prkwars/gameover.rb, line 12 def initialize(score, options = {}) super(options) 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
Public Instance Methods
play()
click to toggle source
Switches the game state. Calls Play.new
instead of just Play
in order to call the initialize method instead of the setup method.
# File lib/prkwars/gameover.rb, line 25 def play switch_game_state(Play.new) end