today we’re honor minecraft with ursina in python
1.install ursina
before program,we should install ursina with this code:
1.1.hold win + r,press"cmd" enter the terminal.
1.2.presspip install ursina
,then wait it install it.
1.3.when it had this “successfuly installed ursina 2.x.x”,you can close the terminal.
2.program
now we have ursina,then start we program
2.1create a txt,then revise the suffix name to py.
2.2then right-click the mouse,choose open in visual studio code(or pycham,notepad++,IDLE)
2.3write this code
`
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
def update():
if held_keys[“left mouse”]:
hands.position = (0.4,-0.5)
elif held_keys[“right mouse”]:
hands.position = (0.4,-0.5)
else:
hands.position = (0.5,-0.6)
def input(key):
if key == “escape”:
quit()
for box in boxes:
if box.hovered:
if key == "left mouse down":
new = Button(
model = "cube",
texture = "brick",
position = box.position + mouse.normal,
parent = scene,
origin_y = 0.5
)
boxes.append(new)
if key == "right mouse down":
boxes.remove(box)
destroy(box)
app = Ursina()
Sky()
player = FirstPersonController()
boxes = []
for n in range(48):
for k in range(48):
box = Button(model=“cube”,color=color.light_gray,position=(k,0,n),parent=scene,origin_y=0.5)
boxes.append(box)
hands = Entity(model=“cube”,color=color.black,parent=camera.ui,rotation=(-35,-30,-5),position=(0.5,-0.6),scale=(0.1,0.2))
app.run()
`
then hold Ctrl+F5,very cool!
