from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
def change_color():
selected_color = ColorPicker(default_color=color.random_color())
selected_color.on_value_changed = on_color_changed
def on_color_changed():
voxel.color = selected_color.color
class Voxel(Button):
def init(self, position=(0,0,0)):
super().init(
parent = scene,
position = position,
model = 'cube',
origin_y = .5,
texture = 'white_cube',
color = color.random_color(),
highlight_color = color.lime,
)
def input(self, key):
if self.hovered:
if key == 'left mouse down':
voxel = Voxel(position=self.position + mouse.normal)
if key == 'right mouse down':
destroy(self)
for z in range(8):
for x in range(8):
voxel = Voxel(position=(x, 0,z))
player = FirstPersonController()
color_button = Button(text='Select Color', position=(-0.5, -0.5))
color_button.on_click = change_color
app.run ()
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
class Voxel(Button):
def __init__(self, position=(0,0,0)):
super().__init__(
parent = scene,
position = position,
model = 'cube',
origin_y = .5,
texture = 'white_cube',
color = color.color(0, 0, random.uniform(.9, 1.0)),
highlight_color = color.lime,
)
def input(self, key):
if self.hovered:
if key == 'left mouse down':
voxel = Voxel(position=self.position + mouse.normal)
if key == 'right mouse down':
destroy(self)
for z in range(8):
for x in range(8):
voxel = Voxel(position=(x, 0,z))
player = FirstPersonController()
app.run ()