I'm developing a game using the Ursina framework in Python (I'm a beginner with Ursina), and I've encountered an issue where the application freezes when I press the escape key to quit the game.
(I know wildcard imports are not good practice, but this is just for tests.)
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=0.5,
texture='white_cube',
color=color.color(0, 0, random.uniform(0.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)
def update():
if held_keys['escape']:
print("Escape key pressed") # Debug statement to check if the event is captured
application.quit()
for z in range(8):
for x in range(8):
voxel = Voxel(position=(x, 0, z))
player = FirstPersonController()
app.run()
Probably useful Information:
Ursina version: 6.1.2
Python version: 3.11.1
Operating system: Windows OS
Any help will be appreciated. Thanks.
What was supposed to happen was that when Escape key was pressed, it would exit the App.
But it Freezes instead.
I've added print statements to track the flow of the code, and I am certain that the update() function is being called when I press the escape key. Also checked for any blocking operations in the code that might cause the freeze, but couldn't find any obvious issues.