-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflag.py
More file actions
33 lines (25 loc) · 767 Bytes
/
flag.py
File metadata and controls
33 lines (25 loc) · 767 Bytes
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
from gameObject import GameObject
from tank import Tank
class Flag(GameObject):
def __init__(self, color, position, size):
image = f'img/{color}_flag.png'
size = (size, size)
self.color = color
self.pickedUpBy = None
self.pickedUp = False
self.startingPosition = position
super().__init__(image, position, size)
def setPickedUp(self, tank):
if (isinstance(tank, Tank) and not self.pickedUpBy):
self.pickedUpBy = tank
self.pickedUp = True
def dropped(self):
self.pickedUpBy = None
self.pickedUp = False
def update(self):
if self.pickedUp:
self.position = self.pickedUpBy.position
super().update()
def respawn(self):
self.position = self.startingPosition
self.updateSides()