0

I want to make Maze-Runner in ursina and change maze according to real time. So, I use 'from datetime import datetime' and get real time in every frame. I want to make the maze change every 6 minutes in reality, but is there a way to create or eliminate entities over time? There is part of my cord.

maze = []
maze1 = Entity(model='cube', origin_y=0, scale=(1, 7, 1), collider='box', color=color.hsv(0, 0, random.uniform(.9, 1)))
new_maze1 = duplicate(maze1, x=0, z=4, y=2)
new_maze2 = duplicate(maze1, x=4, z=0, y=2)

def update():
    if held_keys['left mouse']:
        shoot()
    global t, hour, minute, second, text
    t = datetime.now()
    hour, minute, second = t.hour, t.minute, t.second

    text.y = 1
    text=Text(f"{str(minute%6).zfill(2)}: {str(second).zfill(2)}", position=(.78,.43),origin=(0,0), scale=2, background=True)

    print(minute%6)

    global new_maze1, new_maze2

    if minute % 6 == 3 and second == 0:
        maze=[]
        maze.append(new_maze1)
        destroy(new_maze2)
        
    elif second == 0 and not minute % 6 == 3:
        maze=[]
        maze.append(new_maze2)
        destroy(new_maze1)
  • You have to keep track of the maze parts you want to change. At the moment, your local `maze` variables shadow the global one because you use an assignment instead of calling a method on the maze object. – Jan Wilamowski Nov 14 '22 at 13:17

1 Answers1

0

You can use invoke and function Like:

invoke (recrete_maze, delay=6000)
Lixt
  • 201
  • 4
  • 19