-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerInputController.py
More file actions
65 lines (52 loc) · 1.78 KB
/
PlayerInputController.py
File metadata and controls
65 lines (52 loc) · 1.78 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from Player import *
class PlayerInputController():
'''
This class is an inbetween for handling and calling input events in a player
This class allows us to easily change key bindings
'''
#constructor sets up initial bindings for keys
def __init__(self, up, down, left, right, act1, act2, key1, key2, key3, player):
self.upKey = up
self.downKey = down
self.leftKey = left
self.rightKey = right
self.actionKey1 = act1
self.actionKey2 = act2
self.keyOne = key1
self.keyTwo = key2
self.keyThree = key3
self.owningPlayer = player
'''
up
down
right
left
shoot
change weapon
weapon1
weapon2
weapon3
'''
def update(self, keyboard):
if(keyboard[self.upKey] == True):
self.owningPlayer.inputUpKeyAction()
#else:
#self.owningPlayer.inputUpKeyRelease()
if(keyboard[self.downKey] == True):
self.owningPlayer.inputDownKeyAction()
if(keyboard[self.rightKey] == True):
self.owningPlayer.inputRightKeyAction()
if(keyboard[self.leftKey] == True):
self.owningPlayer.inputLeftKeyAction()
if(keyboard[self.actionKey1] == True):
self.owningPlayer.inputAction1()
#else:
#self.owningPlayer.releaseAction1()
if(keyboard[self.actionKey2] == True):
self.owningPlayer.inputAction2()
if(keyboard[self.keyOne] == True):
self.owningPlayer.inputKey1()
if(keyboard[self.keyTwo] == True):
self.owningPlayer.inputKey2()
if(keyboard[self.keyThree] == True):
self.owningPlayer.inputKey3()