Module: Swarm
- Defined in:
- lib/swarm.rb,
lib/swarm/map.rb,
lib/swarm/game.rb,
lib/swarm/tile.rb,
lib/swarm/level.rb,
lib/swarm/catalog.rb,
lib/swarm/console.rb,
lib/swarm/version.rb,
lib/swarm/levels/one.rb,
lib/swarm/levels/two.rb,
lib/swarm/levels/five.rb,
lib/swarm/levels/four.rb,
lib/swarm/levels/intro.rb,
lib/swarm/levels/three.rb,
lib/swarm/levels/example.rb
Overview
Namespace for classes and modules of the Swarm
application.
Defined Under Namespace
Modules: Console Classes: Catalog, Five, Four, Game, Intro, Level, Map, One, Three, Tile, Two
Constant Summary
- VERSION =
'1.0.3'
Class Method Summary collapse
-
.start ⇒ Kernel#exit
Initialize the console, launch the game, play the game, print the scoreboard and exit to the shell.
Class Method Details
.start ⇒ Kernel#exit
Initialize the console, launch the game, play the game, print the scoreboard and exit to the shell.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/swarm.rb', line 30 def self.start Signal.trap('INT') { game.stop } # Ctrl-C stops the game gracefully game = Game.new Console.open do game.start Level.each do |level| next if game.over? game.setup! level game.show! game.play! until game.over? || level.over? end game.stop end puts game exit true # success! rescue => error Console.close warn 'Swarm encountered an unhandled error' warn error., *error.backtrace exit false # failure! end |