(有ursina库)
CODE:
from ursina import *
from ursina import Ursina
from ursina.prefabs.first_person_controller import FirstPersonController
import ursina
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)
def input(key):
global block
if key == '1':
block = 'block_img/diamond_block.png';
if key == '2':
block = 'block_img/gold_block.png';
if key == '3':
block = 'block_img/green_block.png';
if key == '4':
block = 'block_img/grass.png';
if key == '5':
block = 'block_img/shazi.png';
if key == '6':
block = 'block_img/a_block.png';
if (key == '7'):
block = 'block_img/stone.png'
if key == '8':
block = 'block_img/bedrock.png'
if key == '9':
block = 'image/blockworld-ico.tiff'
if (key == "escape"):
quit()
for box in boxes:
if box.hovered:
if (key == "left mouse down"):
new = Button(
model="cube",
color=color.white,
position=box.position + mouse.normal,
parent=scene,
texture=block,
origin_y=0.5
)
boxes.append(new)
if (key == "right mouse down"):
boxes.remove(box)
destroy(box)
for br in brs:
if br.hovered:
if key == "right mouse down":
brs.remove(br)
destroy(br)
if key == "left mouse down":
new = Button(
model="cube",
color=color.white,
position=br.position + mouse.normal,
texture=block,
parent=scene,
origin_y=1.5
)
brs.append(new)
app: Ursina = ursina.Ursina()
Sky()
player = FirstPersonController()
boxes = []
brs = []
bars = []
for n in range(25):
for k in range(25):
box = Button(model="cube",
color=color.white,
position=(k, 0, n),
texture='block_img/grass.png',
parent=scene,
origin_y=0.5)
boxes.append(box)
for n in range(25):
for k in range(25):
br = Button(model="cube",
color=color.white,
position=(k, 0, n),
texture='block_img/stone.png',
parent=scene,
origin_y=1.5)
brs.append(br)
for n in range(-2, 27, 1):
for k in range(-2, 27, 1):
br = Button(model="cube",
color=color.white,
position=(k, 0, n),
texture='block_img/bedrock.png',
parent=scene,
origin_y=5.5)
brs.append(br)
sword = Entity(model="cube",
color=color.white,
texture="image/hand.jpg",
parent=camera.ui,
rotation=(-35, -30, -5),
position=(0.5, -0.6),
scale=(0.1, 0.2))
block = 'image/blockworld-ico.tiff'
app.run()
贴图有点多,下期打包发
共 2 条回复
cmd命令: python -m pip install ursina
6666