Skip to content

Instantly share code, notes, and snippets.

@JamesZoft
Created March 28, 2012 14:58
Show Gist options
  • Save JamesZoft/2226870 to your computer and use it in GitHub Desktop.
Save JamesZoft/2226870 to your computer and use it in GitHub Desktop.
def move(direction) #Returns what the new coords would be, Sokoban.handle_move then checks if these are valid
pp @coordinates
case direction.downcase!
when "up"
move_up()
when "down"
move_down()
when "right"
move_right()
when "left"
move_left()
end
end
#The third entry in these return values are whether the man moved up, down, right or left for the Sokoban.handle_move
def move_up()
[@coordinates[0] - 1, @coordinates[1], "up"]
end
def move_down()
[@coordinates[0] + 1, @coordinates[1], "down"]
end
def move_right()
[@coordinates[0], @coordinates[1] + 1, "right"]
end
def move_left()
[@coordinates[0], @coordinates[1] - 1, "left"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment