From 9f5b5136e1ee9ef3f27388bcf29e1bffbc654f5d Mon Sep 17 00:00:00 2001 From: Kylin_on_Mac Date: Fri, 22 Sep 2023 15:45:51 +0800 Subject: [PATCH] feat: set playground size in init --- game_config.json | 10 +++++++++- src/game.py | 13 +++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/game_config.json b/game_config.json index 36a95a5..c142412 100644 --- a/game_config.json +++ b/game_config.json @@ -36,13 +36,21 @@ "default": 10 }, { - "name": "score", + "name": "score_to_win", "verbose": "通關分數", "type": "int", "min": 1, "max": 30, "default": 10, "help": "set the score to win this game " + }, + { + "name": "playground_size", + "verbose": "場地尺寸", + "type": "list", + + "default": "500,400", + "help": "set the size of playground " } ] } \ No newline at end of file diff --git a/src/game.py b/src/game.py index 9d5846a..2ac9dbe 100644 --- a/src/game.py +++ b/src/game.py @@ -25,12 +25,12 @@ class EasyGame(PaiaGame): """ def __init__( - self, time_to_play, score, green_food_count, black_food_count, - # playground_size + self, time_to_play, score_to_win, green_food_count, black_food_count, + playground_size:list, *args, **kwargs): super().__init__(user_num=1) - self.playground_w = 400 - self.playground_h = 300 + self.playground_w = int(playground_size[0]) + self.playground_h = int(playground_size[1]) self.game_result_state = GameResultState.FAIL self.scene = Scene(width=WIDTH, height=HEIGHT, color=BG_COLOR, bias_x=0, bias_y=0) @@ -42,7 +42,7 @@ class EasyGame(PaiaGame): self.playground.center = (WIDTH / 2, HEIGHT / 2) self.green_food_count = green_food_count self.black_food_count = black_food_count - self.score_to_win = score + self.score_to_win = score_to_win self.frame_limit = time_to_play self.foods = pygame.sprite.Group() @@ -186,7 +186,8 @@ class EasyGame(PaiaGame): { "player": get_ai_name(0), "rank": 1, - "score": self.score + "score": self.score, + "passed":self.score>self.score_to_win } ]