[英]How to make and remove entity according to time in ursina
我想在ursina中制作Maze-Runner並根據實時改變迷宮。 因此,我使用“from datetime import datetime”並在每一幀中獲取實時時間。 我想讓迷宮在現實中每 6 分鍾改變一次,但是有沒有辦法隨着時間的推移創建或消除實體? 我的繩子有一部分。
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)
您可以使用 invoke 和 function Like:
invoke (recrete_maze, delay=6000)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.