-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdonkey.py
49 lines (40 loc) · 1.33 KB
/
donkey.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
from barrel import Barrel
class Donkey:
def __init__(self):
self.__posX = 16 #Donkey's position in the X axis
self.__posY = 38 #Donkey's position in the Y axis
self.__counter = 1 #This attribute is used for naming the barrels Donkey throws
self.__throwing = False #Triggers animation
self.__grabbing_barrel = False #Triggers animation
self.__waiting = False #Triggers animation
def throwBarrel(self): #This function creates a barrel object, returning both the object and a name (that will be used as a key in the barrels dictionary)
name = 'barrel_' + str(self.__counter)
obj = Barrel()
self.__counter += 1
return name, obj
#GETTERS
@property
def posX(self):
return self.__posX
@property
def waiting(self):
return self.__waiting
@property
def grabbing_barrel(self):
return self.__grabbing_barrel
@property
def posY(self):
return self.__posY
@property
def throwing(self):
return self.__throwing
#SETTERS
@waiting.setter
def waiting(self, value):
self.__waiting = value
@throwing.setter
def throwing(self, value):
self.__throwing = value
@grabbing_barrel.setter
def grabbing_barrel(self, value):
self.__grabbing_barrel = value