猫史档案馆


做出来了一个沙盒

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


center_image

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()

用到了第三方库


回复

上一页1 页 / 共 1下一页
76947694

A D W S 移动

空格 跳跃

1,2切换物品

点赞1


评论