-
-
Save JamesZoft/2226870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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