-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScore.py
52 lines (39 loc) · 1.2 KB
/
Score.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
'''
Score class:
This class keep the score as well as the time as the score has not updated
'''
class Score():
#Constructor
def __init__(self, start_position_x, tile_size):
self.distance_score = 0
self.plus_score = 0
self.minus_score = 0
self.final_score = 0
self.start_position_x = start_position_x
self.tile_size = tile_size
self.counter = 0
#Reset all variable that could be changed
def restore(self):
self.distance_score = 0
self.plus_score = 0
self.minus_score = 0
self.final_score = 0
self.counter = 0
#Update the score depending on the distance
def update_score(self, player_postion_x):
new_score =int((player_postion_x-self.start_position_x) / self.tile_size)
#Make sure that the score does not decrease if going backwards and count the
#frames that the AI does not move
if new_score>self.distance_score:
self.distance_score = new_score
self.counter = 0
else:
self.counter +=1
def add_to_score(self, points):
self.plus_score += points
def minus_to_score(self, points):
self.minus_score += points
def get_highscore_still(self):
return self.counter
def get_score(self):
return self.distance_score + self.plus_score - self.minus_score