-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameHandler.py
56 lines (53 loc) · 1.7 KB
/
gameHandler.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
45
46
47
48
49
50
51
52
53
54
55
56
from buildCharacter import bullet
def mandoHandler(board, mando, char):
'''Handles movement, firing of gun etc'''
if char == "w":
canMove = board.check(mando, char)
if canMove:
board.removeMando(mando)
mando.moveUp()
board.moveMando(mando)
elif char == "s":
canMove = board.check(mando, char)
if canMove:
board.removeMando(mando)
mando.moveDown()
board.moveMando(mando)
elif char == "d":
canMove = board.check(mando, char)
if canMove:
board.removeMando(mando)
mando.moveRight()
board.moveMando(mando)
# Gravity
canMove = board.check(mando, "s")
if canMove:
board.removeMando(mando)
mando.moveDown()
board.moveMando(mando)
elif char == "a":
canMove = board.check(mando, char)
if canMove:
board.removeMando(mando)
mando.moveLeft()
board.moveMando(mando)
# Gravity
canMove = board.check(mando, "s")
if canMove:
board.removeMando(mando)
mando.moveDown()
board.moveMando(mando)
elif char == "":
# Gravity
canMove = board.check(mando, "s")
if canMove:
board.removeMando(mando)
mando.moveDown()
board.moveMando(mando)
elif char == " ":
c = board.shieldChecker(mando)
if c == 1:
mando.shieldToggle = 1
elif char == "b":
newBullet = bullet(mando.position_x + mando.bodyWidth, -mando.position_y + 1 - board.groundSize - mando.bodyHeight)
board.bulletArray.append(newBullet)