Trying to make a random maze that changes every 10 seconds

I am trying to make a random maze that changes every 10 seconds. I’m on the Game Dev 2 Final Project, and I wanted to do something interesting. For some reason, though, I can’t get new mazes to spawn or old ones to be destroyed. The first maze spawns in, and it uses the same code as the second, but the second one fails to spawn in for some reason. I also can’t get the destroy method to work, no matter what I do. This may stem from me trying to destroy a whole screen of forest tiles at once.
My current code looks like this. Thanks in advance!

#The player
game.spawnPlayerXY("knight", 8, 8)
ui.track(game, "time")

#The problem
if game.time == 0:
    maze1 = game.spawnMaze("forest", game.randomInteger(0, 500))
if game.time == 10:
    maze2 = game.spawnMaze("forest", game.randomInteger(0, 500))
if game.time == 20:
    game.time == 0

Sry, cant help you, but I just am here to say, that is an amazing idea!

1 Like

I finally figured out how to change the maze every 10 seconds, but not how to destroy the objects. Please don’t tell me there is only one way to do that function, that would be really dumb.

I finally figured it out, but code combat is bugged. Destroying a collectible or an enemy with behavior will only remove their sprite and movement possibilities, making it so that you can collect something that was destroyed forever, as well as invisible ogres that can still attack. It’s very broken.

Code Combat doesn’t even have a solution for this! Try in on run for gold. Wait for a gem to despawn and stand where it once stood. Your high score will skyrocket!

You might want to check out stranded in the desert level. I don’t destroy anything except landscape items but the level works like this.

It re-uses elements and randomly places rocks etc. the player enters the area and there are monsters spawned in waves. When the monsters are all dead and player reaches right side of the screen it lets them proceed to the next screen. It’s just the same screen though and places player at left of screen again with a new configuration. Rinse repeat a few times. Then finally a final configuration where the boss fight is.

Try using .setExists(false) on items objects enemies etc.


Oh hey, thanks for the reply! I solved the issue previously and ignored the bug, but I’m not sure how to mark it as solved.