用户:
7694查看:0 回复:1 评论:0 创建时间:2024-01-26T22:59:49
import random
from ursina import *
from ursina.shaders import lit_with_shadows_shader
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
a = 0
c = True
s = ['grass','brick','wood.png','jiyan.png']
camera = EditorCamera(enabled = False)
def input(key):
global a,c
if key == 'tab':
camera.enabled = not camera.enabled
mouse.locked = not camera.enabled
parent = player
c = not camera.enabled
if key == 'escape':quit()
if key == '1':a=0
if key == '2':a=1
if key == '3':a=2
if key == '4':a=3
for box in boxes:
if box.hovered:
if key == "left mouse down" and c:
new = Button(model = 'cube',
color = color.white,
position = box.position+mouse.normal,
texture = s[a],
parent = scene,
origin_y = 0.5)
boxes.append(new)
if key == "right mouse down" and c:
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)
player = FirstPersonController()
boxes = []
for i in range(32):
for j in range(32):
box=Button(model = 'cube',
color = color.white,
position = (j,0,i),
texture = s[3],
parent = scene,
origin_y = 0.5)
boxes.append(box)
for i in range(32):
for j in range(32):
for y in range(1,2):
box1=Button(model = 'cube',
color = color.white,
position = (j,y,i),
texture = s[0],
parent = scene,
origin_y = 0.5)
boxes.append(box1)
Entity.boxes = lit_with_shadows_shader # 光影default_shader
app.run()
jiyan.png

wood.png
