-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputManager.py
39 lines (26 loc) · 953 Bytes
/
InputManager.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
import pygame
class InputManager:
def __init__(self):
self.moveLeft = False
self.moveRight = False
self.accelerate = False
self.decelerate = False
def onEvent(self, event):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
self.moveRight = True
if event.key == pygame.K_a:
self.moveLeft = True
if event.key == pygame.K_s:
self.decelerate = True
if event.key == pygame.K_w:
self.accelerate = True
if event.type == pygame.KEYUP:
if event.key == pygame.K_d:
self.moveRight = False
if event.key == pygame.K_a:
self.moveLeft = False
if event.key == pygame.K_s:
self.decelerate = False
if event.key == pygame.K_w:
self.accelerate = False