-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.py
30 lines (26 loc) · 995 Bytes
/
control.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
import pygame
from pygame.locals import *
class Control:
def __init__(self):
self.moverate = 5
self.rotateLeft = False
self.rotateRight = False
self.moveUp = False
def update(self, event):
if event.type == KEYDOWN:
if event.key in (K_UP, K_w):
self.moveUp = True
elif event.key in (K_LEFT, K_a):
self.rotateRight = False
self.rotateLeft = True
elif event.key in (K_RIGHT, K_d):
self.rotateLeft = False
self.rotateRight = True
elif event.type == KEYUP:
# stop moving the player's squirrel
if event.key in (K_LEFT, K_a):
self.rotateLeft = False
elif event.key in (K_RIGHT, K_d):
self.rotateRight = False
elif event.key in (K_UP, K_w):
self.moveUp = False