feat: add food1 img
BIN
asset/img/background.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
asset/img/food_01.png
Normal file
After Width: | Height: | Size: 191 KiB |
BIN
asset/img/food_02.png
Normal file
After Width: | Height: | Size: 223 KiB |
BIN
asset/img/food_03.png
Normal file
After Width: | Height: | Size: 225 KiB |
BIN
asset/img/garbage_01.png
Normal file
After Width: | Height: | Size: 169 KiB |
BIN
asset/img/garbage_02.png
Normal file
After Width: | Height: | Size: 298 KiB |
BIN
asset/img/garbage_03.png
Normal file
After Width: | Height: | Size: 299 KiB |
BIN
asset/img/squid.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
asset/logo.png
Normal file
After Width: | Height: | Size: 156 KiB |
Before Width: | Height: | Size: 82 KiB |
@ -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
|
||||
|
||||
|
11
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
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -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": {}
|
||||
}
|
||||
|
@ -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
|