Advertisement
xFazz

proc. gen. mazes

Feb 12th, 2022
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. row = 0
  2. for height in range(map_height):
  3. pos1 = 0
  4. pos2 = 1
  5. for width in range(map_width):
  6. if (row == 0) or (row == map_height-1) or (pos1 == 0) or (pos1 == map_width-1):
  7. dungeon.tiles[pos1:pos2, row] = tile_types.wall
  8. else:
  9.  
  10. dungeon.tiles[pos1:pos2, row] = random.choice([tile_types.floor, tile_types.wall])
  11. pos1 += 1
  12. pos2 += 1
  13. row += 1
  14.  
  15. for i in range(10):
  16. row = 0
  17. for height in range(map_height):
  18. pos1 = 0
  19. pos2 = 1
  20. for width in range(map_width):
  21. if (row == 0) or (row == map_height - 1) or (pos1 == 0) or (pos1 == map_width - 1):
  22. pass
  23. else:
  24. wall_count = 0
  25.  
  26. north = dungeon.tiles[pos1:pos2, row - 1][0][0]
  27. if north == True:
  28. wall_count += 1
  29. north_east = dungeon.tiles[pos1 + 1:pos2 + 1, row - 1][0][0]
  30. if north_east == True:
  31. wall_count += 1
  32. east = dungeon.tiles[pos1 + 1:pos2 + 1, row][0][0]
  33. if east == True:
  34. wall_count += 1
  35. south_east = dungeon.tiles[pos1 + 1:pos2 + 1, row + 1][0][0]
  36. if south_east == True:
  37. wall_count += 1
  38. south = dungeon.tiles[pos1:pos2, row + 1][0][0]
  39. if south == True:
  40. wall_count += 1
  41. south_west = dungeon.tiles[pos1 - 1:pos2 - 1, row + 1][0][0]
  42. if south_west == True:
  43. wall_count += 1
  44. west = dungeon.tiles[pos1 - 1:pos2 - 1, row][0][0]
  45. if west == True:
  46. wall_count += 1
  47. north_west = dungeon.tiles[pos1 - 1:pos2 - 1, row - 1][0][0]
  48. if north_west == True:
  49. wall_count += 1
  50.  
  51.  
  52. if wall_count >= 5:
  53. dungeon.tiles[pos1:pos2, row] = tile_types.wall
  54. elif wall_count < 5:
  55. dungeon.tiles[pos1:pos2, row] = tile_types.floor
  56.  
  57. # tile = (dungeon.tiles[pos1:pos2:, row])
  58. # tile_walkability = tile[0][0]
  59. # print(tile, tile_walkability)
  60.  
  61. pos1 += 1
  62. pos2 += 1
  63. row += 1
  64.  
  65. return dungeon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement