I'm trying to run my program:
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
window.fullscreen = True
class Voxel(Button):
def __init__(self, colour, position = (0, 0, 0)):
super().__init__(
parent = scene,
position = position,
model = "cube",
orgin_y = 0.5,
texture = "white_cube",
color = colour,
)
def start_game(self):
self.colour = color.white
def input(self, key):
if self.hovered:
if key == "right mouse up":
voxel = Voxel(position = self.position + mouse.normal, colour = self.colour)
if key == "left mouse up":
destroy(self)
if key == "0":
self.colour = color.white
if key == "1":
self.colour = color.lime
for z in range(22):
for x in range(22):
voxel = Voxel(position = (x, 0, z), colour = color.lime)
voxel.start_game()
player = FirstPersonController()
app.run()
I'm using python 3.10.6 and Idle.
When I run the program it works as expected except when I choose green after I place a block it turn into white. If I spam click I get the error:
File "C:\Users\game.py", line 24, in input
voxel = Voxel(position = self.position + mouse.normal, colour = self.colour)
AttributeError: 'Voxel' object has no attribute 'colour'