fix: reset game when timeout
This commit is contained in:
parent
b8438b34e5
commit
7be8491973
12
src/game.py
12
src/game.py
|
@ -22,6 +22,8 @@ class EasyGame(PaiaGame):
|
||||||
super().__init__(user_num=1)
|
super().__init__(user_num=1)
|
||||||
self.game_result_state = GameResultState.FAIL
|
self.game_result_state = GameResultState.FAIL
|
||||||
self.scene = Scene(width=800, height=600, color="#4FC3F7", bias_x=0, bias_y=0)
|
self.scene = Scene(width=800, height=600, color="#4FC3F7", bias_x=0, bias_y=0)
|
||||||
|
self.total_point_count = total_point_count
|
||||||
|
self.color = color
|
||||||
print(color)
|
print(color)
|
||||||
self.ball = Ball("#" + color)
|
self.ball = Ball("#" + color)
|
||||||
self.foods = pygame.sprite.Group()
|
self.foods = pygame.sprite.Group()
|
||||||
|
@ -57,7 +59,7 @@ class EasyGame(PaiaGame):
|
||||||
# self.draw()
|
# self.draw()
|
||||||
|
|
||||||
if not self.is_running:
|
if not self.is_running:
|
||||||
return "QUIT"
|
return "RESET"
|
||||||
|
|
||||||
def get_data_from_game_to_player(self):
|
def get_data_from_game_to_player(self):
|
||||||
"""
|
"""
|
||||||
|
@ -93,6 +95,14 @@ class EasyGame(PaiaGame):
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
self.score = 0
|
||||||
|
self._begin_time = time.time()
|
||||||
|
self._timer = 0
|
||||||
|
self.frame_count = 0
|
||||||
|
self.ball = Ball("#" + self.color)
|
||||||
|
|
||||||
|
self.foods = pygame.sprite.Group()
|
||||||
|
self._create_foods(self.total_point_count)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in New Issue