so I am laying the foundations for a small project within my computer science class and I am still relatively new to programming with python, and this is my first real project with Ursina 3D game engine for python.
Anyway, I am remaking an aim trainer, like Kovaaks, and I would like to implement a challenge feature, where when I press tab, (eventually the play button), it starts a 60 second timer, clears the points to 0, then stops recording the points when the timer ends. However, every time I try to implement a sleep timer, it freezes the whole program and never actually starts anything. How could I do this?
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 5 16:46:24 2021
@author: gf112234
"""
import random
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
##########
# update #
##########
def update():
pass
#########
# start #
#########
def targetspawn():
xpos = random.randrange(-10,10)
ypos = random.randrange(-6,6)
zpos = random.randrange(17,20)
return xpos, ypos, zpos
points = -3
def spawn():
global points
points += 1
xpos, ypos, zpos = targetspawn()
target1.position=(xpos, ypos, zpos)
def spawn2():
global points
points += 1
xpos, ypos, zpos = targetspawn()
target2.position=(xpos, ypos, zpos)
def spawn3():
global points
points += 1
xpos, ypos, zpos = targetspawn()
target3.position=(xpos, ypos, zpos)
def input(key):
if key == 'tab':
global points
points = 0
# print(points)
######################
# Application Window #
######################
app = Ursina()
window.title = 'Static-Click 3 Targets'
window.borderless = False
window.fullscreen = True
mouse.locked = True
ground = Entity(model='plane', scale=(2,1,1), color=color.blue, collider='box')
crosshair = Entity(parent=camera.ui, model='quad', color=color.pink, scale=0.007, rotation_z=45)
player = FirstPersonController(y=0, origin_y=0, mouse_sensitivity=(10,10))
target1 = Button(parent=scene, model='sphere', color=color.blue, position=(0 ,0, 0), collider='sphere')
spawn()
target2 = Button(parent=scene, model='sphere', color=color.red, position=(0 ,0, 0), collider='sphere')
spawn2()
target3 = Button(parent=scene, model='sphere', color=color.yellow, position=(0 ,0, 0), collider='sphere')
spawn3()
target1.on_click = spawn
target2.on_click = spawn2
target3.on_click = spawn3
input('tab')
update()
app.run()