forked from sd17fall/InteractiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTime.py
More file actions
36 lines (30 loc) · 930 Bytes
/
Time.py
File metadata and controls
36 lines (30 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Subeen Kim
Input handling & time
"""
import pygame, time
pygame.init()
pygame.display.set_mode((400,300))
pygame.display.set_caption('Mouse Input Test')
"""pause untile frames_per_sec has passed"""
clock = pygame.time.Clock()
frames_per_sec = 30
"""
Input Handling
pygame.event.wait() : sit and block further game execution until an events comes along
pygame.event.poll() : will see whether there are any events wating for processing
pygame.event.get() : returns all of the currently-outstanding events
"""
playtime = 0
running = True
while running:
seconds = clock.tick(frames_per_sec)//30
playtime += seconds
for event in pygame.event.get():
if event.type == QUIT:
running = False
if event.type == KEYDOWN and event.key == K_ESCAPE:
running = False
if event.type == MOUSEBUTTONDOWN:
print (event.button)
pygame.display.quit()