Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple CPS counter
#1
I am trying to make a CPS counter, you will press a button and the timer starts then it will record your CPS and display it at the end of the second.

My trouble is the timer, time.sleep() doesn't work as that would stop everything, so I need a simple timer.

Here is the code so far.

import turtle
cps = 0 #is the CPS goes up when seconddone = False and sets to 0 when seconddone = True
seconddone = True #tells when the timer starts 
wn = turtle.Screen()
wn.setup(width=200, height=200)
wn.bgcolor("white")

cpsb = turtle.Turtle()
cpsb.shape("square")
cpsb.color("black")
cpsb.goto(0,0)

def start():
    seconddone = False
def click():
    cps = cps + 1

wn.onscreenclick(click, 1)
wn.onscreenclick(start, 3)
wn.onkeypress()
wn.listen()
while True:
    wn.update()
while seconddone:
    cps = 0
if anyone could help with making a timer that would be great (note I dont want to optimize the code at this point)
Reply


Messages In This Thread
Simple CPS counter - by GalaxyCoyote - Jun-09-2019, 05:09 PM
RE: Simple CPS counter - by SheeppOSU - Jun-09-2019, 07:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  simple counter mcmxl22 13 7,746 Feb-04-2018, 04:36 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020