Module: SpaceDozer

Defined in:
lib/spacedozer.rb,
lib/spacedozer/map.rb,
lib/spacedozer/tile.rb,
lib/spacedozer/game.rb,
lib/spacedozer/console.rb,
lib/spacedozer/version.rb

Overview

Namespace for classes and modules of the SpaceDozer application.

Defined Under Namespace

Modules: Console Classes: Game, Map, Tile

Constant Summary collapse

VERSION =
'1.0.7'

Class Method Summary collapse

Class Method Details

.startKernel#exit

Initialize the console, launch the game, play the game, print the scoreboard and exit to the shell.

Returns:

  • (Kernel#exit)

    exit to shell with success/failure status code


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/spacedozer.rb', line 17

def self.start
  game = Game.new

  Signal.trap('INT') { game.stop } # Ctrl-C stops the game gracefully

  Console.open do
    game.start
    game.play until game.over?
  end

  puts 'Game Over'
  puts
  puts game

  exit true # success!
rescue => error
  Console.close

  warn 'SpaceDozer encountered an error'
  warn error.message, *error.backtrace
  exit false # failure!
end