#MinecraftНаПитоне
Код из видео:
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
class Voxel(Button):
def init(self, position=(0, 0, 0)):
super().init(
parent=scene,
position=position,
model='cube',
origin_y=0.5,
texture='white_cube',
color=color.white,
highlight_color=color.lime
)
def input(self, key):
if self.hovered:
if key == 'right mouse down':
voxel = Voxel(position=self.position + mouse.normal)
if key == 'left mouse down':
destroy(self)
app = Ursina()
for z in range(15):
for x in range(15):
voxel = Voxel(position=(x, 0, z))
player = FirstPersonController()
app.run()
Код из видео:
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
class Voxel(Button):
def init(self, position=(0, 0, 0)):
super().init(
parent=scene,
position=position,
model='cube',
origin_y=0.5,
texture='white_cube',
color=color.white,
highlight_color=color.lime
)
def input(self, key):
if self.hovered:
if key == 'right mouse down':
voxel = Voxel(position=self.position + mouse.normal)
if key == 'left mouse down':
destroy(self)
app = Ursina()
for z in range(15):
for x in range(15):
voxel = Voxel(position=(x, 0, z))
player = FirstPersonController()
app.run()