用户:
7694查看:2 回复:1 评论:2 创建时间:2024-01-25T22:18:35

import random
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
a = 0;
def input(key):
global a;
if key == 'escape':
quit();
if key == '1':
a=0;
if key == '2':
a=1;
for box in boxes:
if box.hovered:
if key == "left mouse down":
if a == 0:
new = Button(model = 'cube',
color = color.white,
position = box.position+mouse.normal,
texture = 'grass',
parent = scene,
origin_y = 0.5)
boxes.append(new)
else:
new = Button(model = 'cube',
color = color.white,
position = box.position+mouse.normal,
texture = 'brick',
parent = scene,
origin_y = 0.5)
boxes.append(new)
if key == "right mouse down":
boxes.remove(box)
destroy(box)
if key == 'm':
player.position=(0,18,0)
def update():
if player.position.y < -20:
player.position=(0,18,0)
Sky()
player = FirstPersonController(position=(0,18,0))
boxes = []
for i in range(32):
for j in range(32):
box=Button(model = 'cube',
color = color.white,
position = (j,0,i),
texture = 'brick',
parent = scene,
origin_y = 0.5)
boxes.append(box)
for i in range(32):
for j in range(32):
for y in range(1,5):
box1=Button(model = 'cube',
color = color.white,
position = (j,y,i),
texture = 'grass',
parent = scene,
origin_y = 0.5)
boxes.append(box1)
app.run()
用到了第三方库