new 2P image

add README.md
This commit is contained in:
yanshaoting 2024-02-02 13:33:23 +08:00
parent e1c7db77ca
commit 697b5f3ff6
5 changed files with 55 additions and 20 deletions

View File

@ -6,7 +6,7 @@
[![pygame](https://img.shields.io/badge/pygame-2.0.1-<COLOR>.svg)](https://github.com/pygame/pygame/releases/tag/2.0.1) [![pygame](https://img.shields.io/badge/pygame-2.0.1-<COLOR>.svg)](https://github.com/pygame/pygame/releases/tag/2.0.1)
這是一個吃東西小遊戲,也是 PAIA 的遊戲教學範例 這是一個魷魚吃東西小遊戲,你需要找到正確的食物、避開海中的垃圾,還要提防敵人的攻擊!(當然你也可以主動攻擊他人)
![demo](https://github.com/PAIA-Playful-AI-Arena/swimming-squid/blob/main/asset/swimming-squid.gif?raw=true) ![demo](https://github.com/PAIA-Playful-AI-Arena/swimming-squid/blob/main/asset/swimming-squid.gif?raw=true)
@ -32,19 +32,44 @@ game = SwimmingSquid(
## 玩法 ## 玩法
- 使用鍵盤 上、下、左、右 控制方塊 - 1P使用鍵盤 上、下、左、右 控制魷魚
- 2P使用鍵盤 W、S、A、D 控制魷魚
## 目標 ## 遊戲規則
1. 在遊戲時間截止前,盡可能吃到愈多的食物吧! ### 角色升級機制
角色初始等級皆為 1隨著得分增加升 / 降級。等級將會影響角色長寬與移動速度,各等級對應資料如下:
| Lv| 角色寬度 | 角色高度 |移動速度|
| --- | ------- | ------ | ------|
| 1 | 30 | 45 |25|
| 2 | 36 | 54 |21|
| 3 | 42 | 63 |18|
| 4 | 48 | 72 |16|
| 5 | 54 | 81 |12|
| 6 | 60 | 90 |9|
### 得分 / 扣分規則
1. 吃東西:
1. 角色可以透過吃海裡漂浮的東西獲取分數,但海裡也有垃圾存在,吃到垃圾將會扣分。
2. 不同的食物 / 垃圾會有不同的大小與分數。
2. 玩家相撞:
1. 當地圖長寬皆大於 500 pixels 時,遊戲將增加碰撞機制。
2. 兩隻魷魚相撞時,如果一方等級較高,則等級高者加 10 分,等級低者扣 10 分。
3. 如果兩方等級相同,則雙方皆扣 5 分。
### 通關條件 ### 通關條件
1. 時間結束前,吃到的食物超過`score`,即可過關。 1. 時間結束前,吃到的食物超過`score`,即可晉級下一關。
2. 若兩人同時通關,分數較高者勝。
3. 若兩人同時通關且同分,遊戲將進入延長賽:提高 `score` 50 分,並且延長遊戲時間 600 frame。
4. 遊戲最多延長 3 次。
### 失敗條件 ### 失敗條件
1. 時間結束前,吃到的食物少於`score`,即算失敗。 1. 時間結束前,吃到的食物少於`score`,即算失敗。
2. 若兩人皆未能達成 `score`,分數較高者勝。
3. 若兩人皆未能達成 `score` 且同分,遊戲將進入延長賽:`score` 維持不變,並且延長遊戲時間 300 frame。
4. 遊戲最多延長 3 次。
--- ---
@ -90,14 +115,18 @@ class MLPlay:
```json ```json
{ {
"frame": 15, "frame": 15,
"collision_mode": True,
"score": 8, "score": 8,
"score_to_pass": 10, "score_to_pass": 10,
"squid_x": 350, "self_x": 100,
"squid_y": 300, "self_y": 300,
"squid_h": 60, "self_w": 30,
"squid_w": 40, "self_h": 45,
"squid_lv": 1, "self_vel": 25,
"squid_vel": 10, "self_lv": 1,
"opponent_x":500,
"opponent_y":400,
"opponent_lv": 2,
"status": "GAME_ALIVE", "status": "GAME_ALIVE",
"foods": [ "foods": [
{ {
@ -153,13 +182,17 @@ class MLPlay:
} }
``` ```
- `frame`:遊戲畫面更新的編號 - `frame`:遊戲畫面更新的編號。
- `squid_x`:玩家角色的X座標,表示方塊的`中心點`座標值,單位 pixel。 - `collision_mode`:本局是否有碰撞模式。
- `squid_y`:玩家角色的Y座標,表示方塊的`中心點`座標值,單位 pixel。 - `self_x`:玩家角色的X座標,表示方塊的`中心點`座標值,單位 pixel。
- `squid_w`:玩家角色的寬度,單位 pixel。 - `self_y`:玩家角色的Y座標,表示方塊的`中心點`座標值,單位 pixel。
- `squid_h`:玩家角色的高度,單位 pixel。 - `self_w`:玩家角色的寬度,單位 pixel。
- `squid_vel`:玩家角色的速度,表示方塊每幀移動的像素,單位 pixel。 - `self_h`:玩家角色的高度,單位 pixel。
- `squid_lv`:玩家角色的等級,最小 1 ,最大 6。 - `self_vel`:玩家角色的速度,表示方塊每幀移動的像素,單位 pixel。
- `self_lv`:玩家角色的等級,最小 1 ,最大 6。
- `opponent_x`:對手角色的X座標,表示方塊的`中心點`座標值,單位 pixel。
- `opponent_y`:對手角色的Y座標,表示方塊的`中心點`座標值,單位 pixel。
- `opponent_lv`:對手角色的等級,最小 1 ,最大 6。
- `foods`:食物的清單,清單內每一個物件都是一個食物的`中心點`座標值,也會提供此食物是什麼類型和分數多少。 - `foods`:食物的清單,清單內每一個物件都是一個食物的`中心點`座標值,也會提供此食物是什麼類型和分數多少。
- `type` 食物類型: `FOOD_1`, `FOOD_2`, `FOOD_3`, `GARBAGE_1`, `GARBAGE_2`, `GARBAGE_3` - `type` 食物類型: `FOOD_1`, `FOOD_2`, `FOOD_3`, `GARBAGE_1`, `GARBAGE_2`, `GARBAGE_3`
- `score`:目前得到的分數 - `score`:目前得到的分數

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -2,7 +2,7 @@
"game_name": "swimming-squid", "game_name": "swimming-squid",
"version": " 1.0", "version": " 1.0",
"url": "https://github.com/PAIA-Playful-AI-Arena/swimming-squid", "url": "https://github.com/PAIA-Playful-AI-Arena/swimming-squid",
"description": "這是一個魷魚吃東西小遊戲,除了讓你熟習所有基本操作,也是 PAIA 的遊戲教學範例", "description": "這是一個魷魚吃東西小遊戲,你需要找到正確的食物、避開海中的垃圾,還要提防敵人的攻擊!(當然你也可以主動攻擊他人)",
"logo": [ "logo": [
"./asset/logo.png", "./asset/logo.png",
"https://raw.githubusercontent.com/PAIA-Playful-AI-Arena/swimming-squid/main/asset/logo.png" "https://raw.githubusercontent.com/PAIA-Playful-AI-Arena/swimming-squid/main/asset/logo.png"

View File

@ -55,7 +55,7 @@ MUSIC_PATH = path.join(path.dirname(__file__), "..", "asset", "music")
BG_PATH = path.join(ASSET_IMAGE_DIR, "background.png") BG_PATH = path.join(ASSET_IMAGE_DIR, "background.png")
SQUID_PATH = path.join(ASSET_IMAGE_DIR, "squid.png") SQUID_PATH = path.join(ASSET_IMAGE_DIR, "squid.png")
SQUID2_PATH = path.join(ASSET_IMAGE_DIR, "squid2_02.png") SQUID2_PATH = path.join(ASSET_IMAGE_DIR, "squid2.png")
IMG_ID_FOOD01_L = "food_01_L" IMG_ID_FOOD01_L = "food_01_L"
IMG_ID_FOOD02_L = "food_02_L" IMG_ID_FOOD02_L = "food_02_L"

View File

@ -186,6 +186,7 @@ class SwimmingSquid(PaiaGame):
data_to_1p = { data_to_1p = {
"frame": self.frame_count, "frame": self.frame_count,
"collision_mode": self._collision_mode,
"self_x": self.squid1.rect.centerx, "self_x": self.squid1.rect.centerx,
"self_y": self.squid1.rect.centery, "self_y": self.squid1.rect.centery,
"self_w": self.squid1.rect.width, "self_w": self.squid1.rect.width,
@ -204,6 +205,7 @@ class SwimmingSquid(PaiaGame):
data_to_2p = { data_to_2p = {
"frame": self.frame_count, "frame": self.frame_count,
"collision_mode": self._collision_mode,
"self_x": self.squid2.rect.centerx, "self_x": self.squid2.rect.centerx,
"self_y": self.squid2.rect.centery, "self_y": self.squid2.rect.centery,
"self_w": self.squid2.rect.width, "self_w": self.squid2.rect.width,