Hey, so Im working on a dungeon crawler thing and this has me completly stumped. This is the code:
var player = PLAYER.instance()
player.position = emptyTiles * GRID_SIZE
player.z_index = PLAYER_LAYER
var stairs_to_make = 2
for stairs_exist in stairs_to_make:
var stairs = STAIRS.instance()
if stairs_exist == 0:
stairs.direction = "Up"
stairs.direction = "Down"
stairs.connect("next_room", self, "generate_new_dungeon")
stairs.position = emptyTiles * GRID_SIZE
stairs.z_index = STAIR_LAYER
var max_items = emptyTiles.size() / 80
var min_items = emptyTiles.size() / 140
print (max_items,",", min_items)
var items_to_spawn = randi() % (max_items - min_items + 1) + min_items
for items in items_to_spawn:
var testitem = TESTITEM.instance()
testitem.position = emptyTiles * GRID_SIZE
print("Before: ", itemlist)
for i in itemlist.size():
print("After: ", itemlist)
if itemlist.size() == 0:
To clarify, all items in the dungeon is spawned at random locations, and all items are Area2D's.
itemlist is an array to keep track of all of them.
emptyTiles is an array with all tiles not occupied by walls.
When the player stands on top of an item some information about it is printed. When the dungeon is reset, all items stop interacting with the player, the only thing working is the walls. Once the scene is reloaded once more, everything returns to normal. I have no idea what is happening. Any help finding out what is going on would be gretly appreciated. If anyone wants to take a look at the code as a whole I would gladly upload the project somewhere for people to look at.