In this game, the player will have to click a hundred times as quickly as possible. However, I need help with calculating the time it takes them to click 100 times.
Or even if I can't count the time, could you help me with creating a count loop once the button is first clicked.
Thanks in advance!
Here's the code:
import time
from scene import *
from PIL import Image
clicks = 0
t=0
class JitterClick(Scene):
def setup(self):
self.button = Button(Rect(self.size.w/2-100, self.size.h/2-140, 200, 200))
self.button.background = Color(0,0,0)
self.button.stroke = Color(0,0,0)
self.button.image = 'Red_Circle'
self.button.action = self.add_clicks
self.add_layer(self.button)
def add_clicks(sender):
global clicks
clicks += 1
def draw(self):
background(0,0,0)
self.button.background = Color(0,0,0)
self.button.draw()
text('Clicks: %i' % clicks, x=self.size.w/2, y=self.size.h/3.8*3, font_size=57)
if clicks == 100:
run(desp())
class desp(Scene):
def setup(self):
self.show_instructions = True
self.p_size = 64 if self.size.w > 700 else 32
def draw(self):
background(0, 0, 0)
text('It took you --\nto click 100\ntimes. You were\nclicking at --', x=self.size.w/2, y=self.size.h/3.8*3, font_size=35)
run(JitterClick())