Skip to content

Instantly share code, notes, and snippets.

@zed

zed/__main__.py Secret

Created October 29, 2014 14:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zed/dcc6ae76487add302371 to your computer and use it in GitHub Desktop.
Save zed/dcc6ae76487add302371 to your computer and use it in GitHub Desktop.
import time
import pygame
pygame.init()
size = (700, 500)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("444ms click")
done = False
clock = pygame.time.Clock()
# from http://soundbible.com/184-Button-Click-On.html
click = pygame.mixer.Sound("Button Click On-SoundBible.com-459633989.wav").play
TICK = pygame.USEREVENT + 1
pygame.time.set_timer(TICK, 440)
timer = pygame.time.get_ticks
start = now = timer()
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == TICK:
now = timer()
print(now - start)
start = now
click()
clock.tick(60)
pygame.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment