feat: change input parameter and food color

This commit is contained in:
Kylin_on_Mac
2023-09-22 11:42:05 +08:00
parent 3a9c44502e
commit 035b84a480
3 changed files with 15 additions and 6 deletions

View File

@ -19,17 +19,17 @@ class EasyGame(PaiaGame):
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)
self.game_result_state = GameResultState.FAIL
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.ball = Ball("#" + color)
self.foods = pygame.sprite.Group()
self.score = 0
self.score_to_win = score
self._create_foods(total_point_count)
self._create_foods(self.total_point_count)
self._begin_time = time.time()
self._frame_count_down = time_to_play
self.frame_limit = time_to_play

View File

@ -4,6 +4,8 @@ import pygame.sprite
from mlgame.view.view_model import create_rect_view_data
FOOD_COLOR = "#009688"
BALL_VEL = 10.5
BALL_H = 50
@ -54,7 +56,7 @@ class Food(pygame.sprite.Sprite):
def __init__(self, group):
pygame.sprite.Sprite.__init__(self, group)
self.image = pygame.Surface([8, 8])
self.color = "#E91E63"
self.color = FOOD_COLOR
self.rect = self.image.get_rect()
self.rect.centerx = random.randint(0, 800)
self.rect.centery = random.randint(0, 600)