Skip to content

Instantly share code, notes, and snippets.

@apgordon
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save apgordon/826a892a76924f066064 to your computer and use it in GitHub Desktop.

Select an option

Save apgordon/826a892a76924f066064 to your computer and use it in GitHub Desktop.
player = []
i = 0
until i == 1
print "Player? "
p = gets.chomp.capitalize
#puts "OK, #{0 - i} players left to enter."
player.push(p)
print "Players entered so far: #{player} \n \n"
i += 1
end
location = ["Square 0", "Square 1", "Square 2", "Square 3"]
player_location = [0,0,0]
x = 0
until x == 3
puts "#{player[0]} is in #{location[player_location[0]]}"
puts "#{player_location[0]}"
print "Move forward <1>, move backward <2>, or quit <3>. "
x = gets.chomp
if x.to_i == 1
puts "Move forward."
player_location[0] += 1
if player_location[0] > 3
puts "No more squares this way; try going backward."
player_location[0] = 3
end
elsif x.to_i ==2
puts "Move backward."
player_location[0] -= 1
if player_location[0] < 0
puts "No more squares this way; try going forward."
player_location[0] = 0
end
elsif x.to_i == 3
break
else puts "You entered '#{x},' which isn't valid. Enter 1, 2, or 3. \n"
end
end
puts "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment