-
Notifications
You must be signed in to change notification settings - Fork 0
/
HUD.py
87 lines (70 loc) · 2.07 KB
/
HUD.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import pyxel
class HUD:
"""
This class will store all the game values such as score, lifes or other relevant parameters.
"""
def __init__(self):
self.lifes = 3
self.score = 0
self.start = False
self.framecount = 0
self.deathframe = 0
# framecount property and setter
@property
def framecount(self):
return self.__framecount
@framecount.setter
def framecount(self, value):
if type(value) != int and type(value) != float:
raise TypeError("framecount must be a number")
else:
self.__framecount = value
# deathframe property and setter
@property
def deathframe(self):
return self.__deathframe
@deathframe.setter
def deathframe(self, value):
if type(value) != int and type(value) != float:
raise TypeError("framecount must be a number")
else:
self.__deathframe = value
# Calculates the real frame_count
@property
def realframecount(self):
"""
This property calculates the real framecount of the program
"""
realframecount = pyxel.frame_count-self.framecount
return realframecount
# lifes property and setter
@property
def lifes(self):
return self.__lifes
@lifes.setter
def lifes(self, value):
if type(value) != int and type(value) != float:
raise TypeError("Lifes must be a number")
else:
self.__lifes = value
# score property and setter
@property
def score(self):
return self.__score
@score.setter
def score(self, value):
if type(value) != int and type(value) != float:
raise TypeError("Score must be a number")
else:
self.__score = value
# start property and setter
@property
def start(self):
return self.__start
@start.setter
def start(self, value):
if type(value) != bool:
raise TypeError("Start must be a bool")
else:
self.__start = value
hud = HUD()