Advertisement
AtEchoOff

Dungeon Crawler Warmup 1

Jun 21st, 2025
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | Source Code | 0 0
  1. # Warm-Up: Where's the Wall?
  2. # Your goal: Check if the adjacent tile of the player is walk-able.
  3.  
  4. # "F" = Floor, "W" = Wall
  5. map_data = [
  6.     ["W", "W", "W", "W", "W"],
  7.     ["W", "F", "F", "F", "W"],
  8.     ["W", "F", "W", "F", "W"],
  9.     ["W", "F", "F", "F", "W"],
  10.     ["W", "W", "W", "W", "W"]
  11. ]
  12.  
  13. def can_move_right(x, y):
  14.     # TODO: Check if the tile to the right is within bounds and is a floor
  15.     return True  # Replace this
  16. def can_move_left(x, y):
  17.     # TODO: Check if the tile to the left is within bounds and is a floor
  18.     return True  # Replace this
  19. def can_move_up(x, y):
  20.     # TODO: Check if the tile to the up is within bounds and is a floor
  21.     return True  # Replace this
  22. def can_move_down(x, y):
  23.     # TODO: Check if the tile to the down is within bounds and is a floor
  24.     return True  # Replace this
  25.  
  26.  
  27.  
  28. # Try testing:
  29. print(can_move_right(1, 1))  # Should return True
  30. print(can_move_left(1, 1))  # Should return False
  31. print(can_move_down(3, 1))  # Should return True
  32. print(can_move_up(3, 1))  # Should return False
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement