diff --git a/asset/img/background.png b/asset/img/background.png new file mode 100644 index 0000000..506cdec Binary files /dev/null and b/asset/img/background.png differ diff --git a/asset/img/food_01.png b/asset/img/food_01.png new file mode 100644 index 0000000..0fc98db Binary files /dev/null and b/asset/img/food_01.png differ diff --git a/asset/img/food_02.png b/asset/img/food_02.png new file mode 100644 index 0000000..8d557e8 Binary files /dev/null and b/asset/img/food_02.png differ diff --git a/asset/img/food_03.png b/asset/img/food_03.png new file mode 100644 index 0000000..c1c62a7 Binary files /dev/null and b/asset/img/food_03.png differ diff --git a/asset/img/garbage_01.png b/asset/img/garbage_01.png new file mode 100644 index 0000000..eb0861c Binary files /dev/null and b/asset/img/garbage_01.png differ diff --git a/asset/img/garbage_02.png b/asset/img/garbage_02.png new file mode 100644 index 0000000..cc51f71 Binary files /dev/null and b/asset/img/garbage_02.png differ diff --git a/asset/img/garbage_03.png b/asset/img/garbage_03.png new file mode 100644 index 0000000..51a23f9 Binary files /dev/null and b/asset/img/garbage_03.png differ diff --git a/asset/img/squid.png b/asset/img/squid.png new file mode 100644 index 0000000..8cce6b3 Binary files /dev/null and b/asset/img/squid.png differ diff --git a/asset/logo.png b/asset/logo.png new file mode 100644 index 0000000..5a024f3 Binary files /dev/null and b/asset/logo.png differ diff --git a/asset/logo.svg b/asset/logo.svg deleted file mode 100644 index 687a4ad..0000000 --- a/asset/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/env.py b/src/env.py index b225bfe..6d850c1 100644 --- a/src/env.py +++ b/src/env.py @@ -21,6 +21,7 @@ BALL_SIZE_MIN = 10 BALL_VEL_MAX = 25 BALL_VEL_MIN = 10 +ASSET_IMAGE_DIR = path.join(path.dirname(__file__), "../asset/img") # food class FoodTypeEnum(StringEnum): GOOD_1 = auto() @@ -38,7 +39,7 @@ FOOD_COLOR_MAP = { FoodTypeEnum.BAD_2: "#FF1744", FoodTypeEnum.BAD_3: "#FF1744" } -FOOD_LV1_SIZE = 8 +FOOD_LV1_SIZE = 20 FOOD_LV2_SIZE = 12 FOOD_LV3_SIZE = 16 diff --git a/src/foods.py b/src/foods.py index 3fedf77..bba39bd 100644 --- a/src/foods.py +++ b/src/foods.py @@ -4,7 +4,7 @@ import pygame.sprite from pygame import Rect from .env import FoodTypeEnum, FOOD_COLOR_MAP, FOOD_LV1_SIZE, FOOD_LV2_SIZE, FOOD_LV3_SIZE -from mlgame.view.view_model import create_rect_view_data +from mlgame.view.view_model import create_rect_view_data, create_image_view_data FOOD1_VEL = 1 @@ -100,6 +100,15 @@ class Food1(Food): self._vel = FOOD1_VEL elif self.rect.right > playground.right and self._vel>0.0: self._vel = - FOOD1_VEL + @property + def game_object_data(self): + return create_image_view_data( + "food01", + self.rect.x, + self.rect.y, + self.rect.width, + self.rect.height + ) diff --git a/src/game.py b/src/game.py index 9e4be0f..e63781c 100644 --- a/src/game.py +++ b/src/game.py @@ -221,9 +221,11 @@ class EasyGame(PaiaGame): # background = create_asset_init_data( # "background", WIDTH, HEIGHT, bg_path, # github_raw_url="https://raw.githubusercontent.com/PAIA-Playful-AI-Arena/easy_game/main/asset/img/background.jpg") + food01_path = path.join(ASSET_IMAGE_DIR, "food_01.png") + food01_url = food01_path scene_init_data = {"scene": self.scene.__dict__, "assets": [ - # background + create_asset_init_data("food01", 20, 20, food01_path,food01_url) ], # "audios": {} } diff --git a/src/game_object.py b/src/game_object.py index 8ab1a81..4bdb154 100644 --- a/src/game_object.py +++ b/src/game_object.py @@ -10,21 +10,23 @@ from .foods import Food from .sound_controller import SoundController from mlgame.view.view_model import create_rect_view_data + class LevelParams(pydantic.BaseModel): - playground_w:int=100 - playground_h:int=200 - score_to_pass:int=10 - time_to_play:int=300 + playground_w: int = 100 + playground_h: int = 200 + score_to_pass: int = 10 + time_to_play: int = 300 - good_food_count:List[int] =[] - bad_food_count:List[int] =[] + good_food_count: List[int] = [] + bad_food_count: List[int] = [] + + food_1: int = 0 + food_2: int = 0 + food_3: int = 0 + garbage_1: int = 0 + garbage_2: int = 0 + garbage_3: int = 0 - food_1:int=0 - food_2:int=0 - food_3:int=0 - garbage_1:int=0 - garbage_2:int=0 - garbage_3:int=0 class Ball(pygame.sprite.Sprite): def __init__(self): @@ -36,7 +38,7 @@ class Ball(pygame.sprite.Sprite): self.rect.center = (400, 300) self._score = 0 self._vel = BALL_VEL - self._lv =1 + self._lv = 1 def update(self, motion): # for motion in motions: @@ -68,22 +70,23 @@ class Ball(pygame.sprite.Sprite): self.color ) - def eat_food_and_change_level_and_play_sound(self, food: Food,sound_controller:SoundController): + def eat_food_and_change_level_and_play_sound(self, food: Food, sound_controller: SoundController): self._score += food.score - new_lv = math.ceil((self._score-BALL_GROWTH_SCORE_STEP + 1) / BALL_GROWTH_SCORE_STEP) - self.rect.width = max(BALL_SIZE_MIN,min(BALL_W + new_lv * BALL_GROWTH_SIZE_STEP, BALL_SIZE_MAX)) - self.rect.height = max(BALL_SIZE_MIN,min(BALL_H + new_lv * BALL_GROWTH_SIZE_STEP, BALL_SIZE_MAX)) - self._vel = max(BALL_VEL_MIN,min(BALL_VEL + new_lv * BALL_GROWTH_VEL_STEP, BALL_VEL_MAX)) + new_lv = math.ceil((self._score - BALL_GROWTH_SCORE_STEP + 1) / BALL_GROWTH_SCORE_STEP) + self.rect.width = max(BALL_SIZE_MIN, min(BALL_W + new_lv * BALL_GROWTH_SIZE_STEP, BALL_SIZE_MAX)) + self.rect.height = max(BALL_SIZE_MIN, min(BALL_H + new_lv * BALL_GROWTH_SIZE_STEP, BALL_SIZE_MAX)) + self._vel = max(BALL_VEL_MIN, min(BALL_VEL + new_lv * BALL_GROWTH_VEL_STEP, BALL_VEL_MAX)) if new_lv > self._lv: sound_controller.play_lv_up() elif new_lv < self._lv: sound_controller.play_lv_down() - self._lv=new_lv + self._lv = new_lv pass @property def score(self): return self._score + @property def vel(self): - return self._vel \ No newline at end of file + return self._vel