-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.rb
More file actions
32 lines (29 loc) · 985 Bytes
/
setup.rb
File metadata and controls
32 lines (29 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "./pacman.rb"
require "./ball.rb"
require "./ghost.rb"
def setup
@pacman = Pacman.new
@regular_ball = Ball.new
@super_ball = Ball.new("super")
@ghost1 = Ghost.new
@ghost2 = Ghost.new
@ghost3 = Ghost.new
@ghost4 = Ghost.new
puts "Welcome to Pacman"
puts "You have #{@pacman.extra_lives} lives."
end
def play_through
10.times { @pacman.eat(@regular_ball) } # points should equal 10000
puts "You have #{@pacman.points} points."
@pacman.eat(@ghost1) # extra lives should decrease by 1 (eq: 1)
puts "You have #{@pacman.extra_lives} lives."
@pacman.eat(@super_ball) # set super_time to 10
puts "You ate a super ball. super_time: #{@pacman.super_time}."
@pacman.eat(@ghost2)
@pacman.eat(@ghost3)
@pacman.eat(@ghost4)
puts "You have #{@pacman.points} points!"
10.times { @pacman.eat(@regular_ball) } # super_time should be less than zero
@pacman.eat(@ghost1)
puts "You have #{@pacman.extra_lives} lives and #{@pacman.points} points."
end