Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Warm-Up: Where's the Wall?
- # Your goal: Check if the adjacent tile of the player is walk-able.
- # "F" = Floor, "W" = Wall
- map_data = [
- ["W", "W", "W", "W", "W"],
- ["W", "F", "F", "F", "W"],
- ["W", "F", "W", "F", "W"],
- ["W", "F", "F", "F", "W"],
- ["W", "W", "W", "W", "W"]
- ]
- def can_move_right(x, y):
- # TODO: Check if the tile to the right is within bounds and is a floor
- return True # Replace this
- def can_move_left(x, y):
- # TODO: Check if the tile to the left is within bounds and is a floor
- return True # Replace this
- def can_move_up(x, y):
- # TODO: Check if the tile to the up is within bounds and is a floor
- return True # Replace this
- def can_move_down(x, y):
- # TODO: Check if the tile to the down is within bounds and is a floor
- return True # Replace this
- # Try testing:
- print(can_move_right(1, 1)) # Should return True
- print(can_move_left(1, 1)) # Should return False
- print(can_move_down(3, 1)) # Should return True
- print(can_move_up(3, 1)) # Should return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement