Skip to content

Commit

Permalink
+ FINISHED! Game Ooooon!!! is over
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jun 11, 2010
1 parent fc20884 commit 6d3b8fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/cern_horror/lib/cern_horror.rb
Expand Up @@ -5,7 +5,7 @@ class CernHorror < GameWindow
size 876, 516

caption "CERN HORROR"
background #'background.png'
background 'background.png'

damping 0.01
gravity 1
Expand All @@ -14,6 +14,11 @@ class CernHorror < GameWindow
collision :player, :debris
collision :baby, :debris

collision :player, :baby do |player, baby|
baby.destroy!
player.save_soul
end

collision :player, :black_hole do |player, _|
player.destroy!
end
Expand Down Expand Up @@ -67,12 +72,15 @@ def gravity_vector_for thing
end

def step
end_game if @black_hole.finished?
end_game if end_game?
create_debris
end

def end_game?
@black_hole.finished? || @player1.destroyed? && @player2.destroyed? && @player3.destroyed?
end
def end_game
p "YOU FAILED"
p "YOU FAILED, THE BLACK HOLE HAS WON!"
exit
end

Expand Down
4 changes: 4 additions & 0 deletions examples/cern_horror/lib/units/player.rb
Expand Up @@ -20,6 +20,10 @@ def initialize *args
self.souls_saved = 0
end

def save_soul
self.souls_saved += 1
end

def move
self.rotation += rand / 1000
self.speed += window.gravity_vector_for(self) / 1000
Expand Down

0 comments on commit 6d3b8fc

Please sign in to comment.