
Lv.1
签名:正是因为我们看不见,那才可怕
在 【少院士讲堂】第四期:用Python做一个图片转黑白字符画程序 中回复
#是3d游戏哦 from ursina import * from ursina.prefabs.\ first_person_controller \ import FirstPersonController
app = Ursina() Sky(texture='sky_sunset') player = FirstPersonController()
boxes = [] for n in range(30): for k inrange(30): box = Button( color=color.blue, model='cube', position=(k, 0, n), texture='assets\grass', parent=scene, origin_y=0.5, ) boxes.append(box)
definput(key): for box in boxes: if box.hovered: if key == 'left mouse down': new = Button( color=color.red, model='cube', position=box.position + mouse.normal, texture='assets\grass', parent=scene, origin_y=0.5, ) boxes.append(new) if key == 'right mouse down': boxes.remove(box) destroy(box)
sword = Entity( model='blade', texture='assets\sword', rotation=(30, -40), position=(0.5, -0.6), parent=camera.ui, scale=(0.2, 0.15) )
def update(): if held_keys['left mouse']: sword.position = (0.4, -0.5) elif held_keys['right mouse']: sword.position = (0.4, -0.5) else: sword.position = (0.5, -0.6)
app.run()
2022-04-08T13:22:18 点赞:0