-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.py
44 lines (40 loc) · 1.33 KB
/
input.py
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
37
38
39
40
41
42
43
44
import pygame
from pygame.locals import *
class Input(object):
def __init__(self):
self.left = False
self.right = False
self.up = False
self.down = False
self.z = False
self.x = False
def update(self):
for event in pygame.event.get():
if event.type == QUIT:
return False
elif event.type == KEYDOWN:
if event.key == K_RIGHT:
self.right = True
elif event.key == K_LEFT:
self.left = True
elif event.key == K_UP:
self.up = True
elif event.key == K_DOWN:
self.down = True
elif event.key == K_z:
self.z = True
elif event.key == K.x:
self.x = True
elif event.type == KEYUP:
if event.key == K_RIGHT:
self.right = False
elif event.key == K_LEFT:
self.left = False
elif event.key == K_UP:
self.up = False
elif event.key == K_DOWN:
self.down = False
elif event.key == K_z:
self.z = False
elif event.key == K.x:
self.x = False