map design

This commit is contained in:
yanshaoting 2024-03-12 10:53:01 +08:00
parent 5baa32b6ef
commit e837db188b
12 changed files with 152 additions and 12 deletions

12
maps/001.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 300,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 10,
"food_1": 5,
"food_2": 0,
"food_3": 0,
"garbage_1": 0,
"garbage_2": 0,
"garbage_3": 0
}

12
maps/002.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 350,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 20,
"food_1": 5,
"food_2": 1,
"food_3": 0,
"garbage_1": 0,
"garbage_2": 0,
"garbage_3": 0
}

12
maps/003.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 500,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 30,
"food_1": 4,
"food_2": 2,
"food_3": 0,
"garbage_1": 3,
"garbage_2": 0,
"garbage_3": 0
}

12
maps/004.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 600,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 40,
"food_1": 8,
"food_2": 2,
"food_3": 0,
"garbage_1": 4,
"garbage_2": 0,
"garbage_3": 0
}

12
maps/005.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 800,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 50,
"food_1": 8,
"food_2": 4,
"food_3": 0,
"garbage_1": 3,
"garbage_2": 1,
"garbage_3": 0
}

12
maps/006.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 1000,
"playground_size_w":400,
"playground_size_h":400,
"score_to_pass": 60,
"food_1": 8,
"food_2": 4,
"food_3": 0,
"garbage_1": 5,
"garbage_2": 2,
"garbage_3": 0
}

12
maps/007.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 1200,
"playground_size_w":500,
"playground_size_h":500,
"score_to_pass": 70,
"food_1": 8,
"food_2": 4,
"food_3": 2,
"garbage_1": 4,
"garbage_2": 2,
"garbage_3": 0
}

12
maps/008.json Normal file
View File

@ -0,0 +1,12 @@
{
"time_to_play": 1400,
"playground_size_w":500,
"playground_size_h":500,
"score_to_pass": 80,
"food_1": 6,
"food_2": 4,
"food_3": 2,
"garbage_1": 3,
"garbage_2": 2,
"garbage_3": 2
}

13
maps/template.json Normal file
View File

@ -0,0 +1,13 @@
{
"time_to_play": 600,
"playground_size_w":650,
"playground_size_h":550,
"score_to_pass": 10,
"food_1": 3,
"food_2": 2,
"food_3": 5,
"garbage_1": 1,
"garbage_2": 1,
"garbage_3": 1
}

41
ml/ml_play_manual_1P.py Normal file
View File

@ -0,0 +1,41 @@
import random
from pprint import pprint
import orjson
import pygame
class MLPlay:
def __init__(self,ai_name,*args,**kwargs):
print("Initial ml script")
def update(self, scene_info: dict, keyboard:list=[], *args, **kwargs):
"""
Generate the command according to the received scene information
"""
# pprint("AI received data from game :", orjson.dumps(scene_info))
# pprint(scene_info)
actions = []
if pygame.K_UP in keyboard:
actions.append("UP")
elif pygame.K_DOWN in keyboard:
actions.append("DOWN")
elif pygame.K_LEFT in keyboard:
actions.append("LEFT")
elif pygame.K_RIGHT in keyboard:
actions.append("RIGHT")
else:
actions.append("NONE")
return actions
def reset(self):
"""
Reset the status
"""
print("reset ml script")
pass

View File

@ -49,7 +49,7 @@ FOOD_LV3_SIZE = 50
# path of assets
ASSET_PATH = path.join(path.dirname(__file__), "..", "asset")
LEVEL_PATH = path.join(path.dirname(__file__), "..", "levels")
LEVEL_PATH = path.join(path.dirname(__file__), "..", "maps")
SOUND_PATH = path.join(path.dirname(__file__), "..", "asset", "sounds")
MUSIC_PATH = path.join(path.dirname(__file__), "..", "asset", "music")

View File

@ -47,7 +47,6 @@ class SwimmingSquid(PaiaGame):
self._used_file = ""
self.foods = pygame.sprite.Group()
self.sound_controller = SoundController(sound)
self._collision_mode = False
self._overtime_count = 0
self._init_game()
@ -74,10 +73,6 @@ class SwimmingSquid(PaiaGame):
game_params.playground_size_w,
game_params.playground_size_h
)
if game_params.playground_size_h >= 500 and game_params.playground_size_w >= 500:
self._collision_mode = True
else:
self._collision_mode = False
self._score_to_pass = game_params.score_to_pass
self._frame_limit = game_params.time_to_play
@ -125,7 +120,6 @@ class SwimmingSquid(PaiaGame):
self._check_foods_collision()
# self._timer = round(time.time() - self._begin_time, 3)
if self._collision_mode:
self._check_squids_collision()
self.frame_count += 1
@ -189,7 +183,6 @@ class SwimmingSquid(PaiaGame):
data_to_1p = {
"frame": self.frame_count,
"collision_mode": self._collision_mode,
"self_x": self.squid1.rect.centerx,
"self_y": self.squid1.rect.centery,
"self_w": self.squid1.rect.width,
@ -208,7 +201,6 @@ class SwimmingSquid(PaiaGame):
data_to_2p = {
"frame": self.frame_count,
"collision_mode": self._collision_mode,
"self_x": self.squid2.rect.centerx,
"self_y": self.squid2.rect.centery,
"self_w": self.squid2.rect.width,
@ -242,9 +234,7 @@ class SwimmingSquid(PaiaGame):
return status
def reset(self):
if self.is_passed:
self._level += 1
self.sound_controller.play_cheer()
else:
self.sound_controller.play_fail()