feat: change input parameter and food color
This commit is contained in:
parent
3a9c44502e
commit
035b84a480
|
@ -21,8 +21,15 @@
|
||||||
"help": "set the limit of frame count , actually time will be revised according to your FPS ."
|
"help": "set the limit of frame count , actually time will be revised according to your FPS ."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "total_point_count",
|
"name": "green_food_count",
|
||||||
"verbose": "總食物數量",
|
"verbose": "綠色食物數量",
|
||||||
|
"type": "int",
|
||||||
|
"choices":[ 5 ,10 ,15,20,25,30,35,40,45,50],
|
||||||
|
"help": "set the total number of points",
|
||||||
|
"default": 10
|
||||||
|
}, {
|
||||||
|
"name": "black_food_count",
|
||||||
|
"verbose": "黑色食物數量",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"choices":[ 5 ,10 ,15,20,25,30,35,40,45,50],
|
"choices":[ 5 ,10 ,15,20,25,30,35,40,45,50],
|
||||||
"help": "set the total number of points",
|
"help": "set the total number of points",
|
||||||
|
|
|
@ -19,17 +19,17 @@ class EasyGame(PaiaGame):
|
||||||
This is a Interface of a game
|
This is a Interface of a game
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, time_to_play, total_point_count, score, color, *args, **kwargs):
|
def __init__(self, time_to_play, green_food_count,black_food_count, score, color, *args, **kwargs):
|
||||||
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="#111111", bias_x=0, bias_y=0)
|
self.scene = Scene(width=800, height=600, color="#111111", bias_x=0, bias_y=0)
|
||||||
self.total_point_count = total_point_count
|
self.total_point_count = green_food_count
|
||||||
self.color = color
|
self.color = color
|
||||||
self.ball = Ball("#" + color)
|
self.ball = Ball("#" + color)
|
||||||
self.foods = pygame.sprite.Group()
|
self.foods = pygame.sprite.Group()
|
||||||
self.score = 0
|
self.score = 0
|
||||||
self.score_to_win = score
|
self.score_to_win = score
|
||||||
self._create_foods(total_point_count)
|
self._create_foods(self.total_point_count)
|
||||||
self._begin_time = time.time()
|
self._begin_time = time.time()
|
||||||
self._frame_count_down = time_to_play
|
self._frame_count_down = time_to_play
|
||||||
self.frame_limit = time_to_play
|
self.frame_limit = time_to_play
|
||||||
|
|
|
@ -4,6 +4,8 @@ import pygame.sprite
|
||||||
|
|
||||||
from mlgame.view.view_model import create_rect_view_data
|
from mlgame.view.view_model import create_rect_view_data
|
||||||
|
|
||||||
|
FOOD_COLOR = "#009688"
|
||||||
|
|
||||||
BALL_VEL = 10.5
|
BALL_VEL = 10.5
|
||||||
|
|
||||||
BALL_H = 50
|
BALL_H = 50
|
||||||
|
@ -54,7 +56,7 @@ class Food(pygame.sprite.Sprite):
|
||||||
def __init__(self, group):
|
def __init__(self, group):
|
||||||
pygame.sprite.Sprite.__init__(self, group)
|
pygame.sprite.Sprite.__init__(self, group)
|
||||||
self.image = pygame.Surface([8, 8])
|
self.image = pygame.Surface([8, 8])
|
||||||
self.color = "#E91E63"
|
self.color = FOOD_COLOR
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.rect.centerx = random.randint(0, 800)
|
self.rect.centerx = random.randint(0, 800)
|
||||||
self.rect.centery = random.randint(0, 600)
|
self.rect.centery = random.randint(0, 600)
|
||||||
|
|
Loading…
Reference in New Issue