feat: set playground size in init
This commit is contained in:
parent
8129c284bd
commit
9f5b5136e1
|
@ -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 "
|
||||
}
|
||||
]
|
||||
}
|
13
src/game.py
13
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
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue