From bd36c3494236e534099ceb5d2ce414d6648ded67 Mon Sep 17 00:00:00 2001
From: Kylin_on_Mac <kylingithubdev@gmail.com>
Date: Fri, 22 Sep 2023 17:29:34 +0800
Subject: [PATCH] refac: change black dot to red dot , update levels file and
 update information on screen

---
 game_config.json   |  4 ++--
 levels/001.json    |  2 +-
 levels/002.json    |  2 +-
 levels/003.json    |  2 +-
 levels/004.json    |  2 +-
 levels/005.json    |  2 +-
 src/enums.py       |  2 +-
 src/game.py        | 34 ++++++++++++++++++++--------------
 src/game_object.py |  2 +-
 9 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/game_config.json b/game_config.json
index 0153002..19bdc1a 100644
--- a/game_config.json
+++ b/game_config.json
@@ -41,8 +41,8 @@
       "default": 10
     },
     {
-      "name": "black_food_count",
-      "verbose": "黑色食物數量",
+      "name": "red_food_count",
+      "verbose": "紅色食物數量",
       "type": "int",
       "choices": [
         5,
diff --git a/levels/001.json b/levels/001.json
index 8327db7..a948b2c 100644
--- a/levels/001.json
+++ b/levels/001.json
@@ -1,5 +1,5 @@
 {
-  "time_to_play": 600,
+  "time_to_play": 300,
   "playground_size": [
     100,
     200
diff --git a/levels/002.json b/levels/002.json
index ce81a47..bb34c84 100644
--- a/levels/002.json
+++ b/levels/002.json
@@ -1,5 +1,5 @@
 {
-  "time_to_play": 600,
+  "time_to_play": 300,
   "playground_size": [
     200,
     200
diff --git a/levels/003.json b/levels/003.json
index d8967b0..af6dd30 100644
--- a/levels/003.json
+++ b/levels/003.json
@@ -1,5 +1,5 @@
 {
-  "time_to_play": 1000,
+  "time_to_play": 500,
   "playground_size": [
     300,
     300
diff --git a/levels/004.json b/levels/004.json
index cf26d15..34d2278 100644
--- a/levels/004.json
+++ b/levels/004.json
@@ -1,5 +1,5 @@
 {
-  "time_to_play": 1000,
+  "time_to_play": 600,
   "playground_size": [
     300,
     300
diff --git a/levels/005.json b/levels/005.json
index b4b44a2..cee2f71 100644
--- a/levels/005.json
+++ b/levels/005.json
@@ -1,5 +1,5 @@
 {
-  "time_to_play": 1000,
+  "time_to_play": 800,
   "playground_size": [
     300,
     300
diff --git a/src/enums.py b/src/enums.py
index 6c630cd..67d67c9 100644
--- a/src/enums.py
+++ b/src/enums.py
@@ -3,4 +3,4 @@ from enum import auto
 from mlgame.utils.enum import StringEnum
 class FoodTypeEnum(StringEnum):
     GREEN = auto()
-    BLACK = auto()
+    RED = auto()
diff --git a/src/game.py b/src/game.py
index b59186b..f69c57d 100644
--- a/src/game.py
+++ b/src/game.py
@@ -27,7 +27,7 @@ class EasyGame(PaiaGame):
     """
 
     def __init__(
-            self, time_to_play, score_to_pass, green_food_count, black_food_count,
+            self, time_to_play, score_to_pass, green_food_count, red_food_count,
             playground_size: list,
             level: int = -1,
             # level_file,
@@ -50,7 +50,7 @@ class EasyGame(PaiaGame):
                 self._playground_h
             )
             self._green_food_count = green_food_count
-            self._black_food_count = black_food_count
+            self._red_food_count = red_food_count
             self._score_to_pass = score_to_pass
             self._frame_limit = time_to_play
             self.playground.center = (WIDTH / 2, HEIGHT / 2)
@@ -80,7 +80,7 @@ class EasyGame(PaiaGame):
             self._playground_h
         )
         self._green_food_count = int(game_params["green_food_count"])
-        self._black_food_count = int(game_params["black_food_count"])
+        self._red_food_count = int(game_params["black_food_count"])
         self._score_to_pass = int(game_params["score_to_pass"])
         self._frame_limit = int(game_params["time_to_play"])
         self.playground.center = (WIDTH / 2, HEIGHT / 2)
@@ -91,7 +91,7 @@ class EasyGame(PaiaGame):
         self.foods.empty()
         self.score = 0
         self._create_foods(self._green_food_count, FoodTypeEnum.GREEN)
-        self._create_foods(self._black_food_count, FoodTypeEnum.BLACK)
+        self._create_foods(self._red_food_count, FoodTypeEnum.RED)
         self.frame_count = 0
         self._frame_count_down = self._frame_limit
 
@@ -116,8 +116,8 @@ class EasyGame(PaiaGame):
                     self.score += 1
                     self._create_foods(1, FoodTypeEnum.GREEN)
 
-                elif food.type == FoodTypeEnum.BLACK:
-                    self._create_foods(1, FoodTypeEnum.BLACK)
+                elif food.type == FoodTypeEnum.RED:
+                    self._create_foods(1, FoodTypeEnum.RED)
                     self.score -= 1
         # self._timer = round(time.time() - self._begin_time, 3)
 
@@ -180,13 +180,13 @@ class EasyGame(PaiaGame):
         Get the initial scene and object information for drawing on the web
         """
         # TODO add music or sound
-        bg_path = path.join(ASSET_PATH, "img/background.jpg")
-        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")
+        # bg_path = path.join(ASSET_PATH, "img/background.jpg")
+        # 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")
         scene_init_data = {"scene": self.scene.__dict__,
                            "assets": [
-                               background
+                               # background
                            ],
                            # "audios": {}
                            }
@@ -203,14 +203,20 @@ class EasyGame(PaiaGame):
         game_obj_list = [self.ball.game_object_data]
         game_obj_list.extend(foods_data)
         backgrounds = [
-            create_image_view_data("background", 0, 0, WIDTH, HEIGHT),
+            # create_image_view_data("background", 0, 0, WIDTH, HEIGHT),
             create_rect_view_data(
                 "playground", self.playground.x, self.playground.y,
                 self.playground.w, self.playground.h, PG_COLOR)
         ]
-        foregrounds = [create_text_view_data(f"Score = {self.score:04d}", 650, 50, "#FF0000", "24px Arial BOLD")]
+        foregrounds = [
+
+        ]
         toggle_objs = [
-            create_text_view_data(f"{self._frame_count_down:04d} frame", 650, 100, "#FFAA00", "24px Arial BOLD")]
+            create_text_view_data(f"Score:{self.score:04d}", 600, 50, "#A5D6A7", "24px Arial BOLD"),
+            create_text_view_data(f" Next:{self._score_to_pass:04d}", 600, 100, "#FF4081", "24px Arial BOLD"),
+            create_text_view_data(f" Time:{self._frame_count_down:04d}", 600, 150, "#FF5722", "24px Arial BOLD"),
+
+        ]
         scene_progress = create_scene_progress_data(frame=self.frame_count, background=backgrounds,
                                                     object_list=game_obj_list,
                                                     foreground=foregrounds, toggle=toggle_objs)
diff --git a/src/game_object.py b/src/game_object.py
index acd649e..bda8172 100644
--- a/src/game_object.py
+++ b/src/game_object.py
@@ -4,7 +4,7 @@ from games.easy_game.src.enums import FoodTypeEnum
 from mlgame.view.view_model import create_rect_view_data
 
 FOOD_COLOR_MAP = {FoodTypeEnum.GREEN: "#009688",
-                  FoodTypeEnum.BLACK: "#263238"}
+                  FoodTypeEnum.RED: "#FF1744"}
 BALL_COLOR = "#FFEB3B"
 BALL_VEL = 10.5