|
|
@@ -21,7 +21,7 @@ from game.const import window as W, color as C, game as G
|
|
|
from game.const import rouge as R
|
|
|
from game.music import music_loader
|
|
|
from game.sound import sound_player
|
|
|
-from game.ui.menu.component import PygameButton, PygameButtonBackIMG
|
|
|
+from game.ui.menu.component import PygameButton, PygameButtonBackIMG, Particle
|
|
|
|
|
|
current_folder_path = os.getcwd()
|
|
|
|
|
|
@@ -55,6 +55,7 @@ class Menu:
|
|
|
def __init__(self, screen, bg_image_path=None):
|
|
|
self.screen = screen
|
|
|
self.buttons = []
|
|
|
+ self.particles = [] # 粒子列表
|
|
|
self.current_hero = "Fox"
|
|
|
self.current_difficulty = "Easy"
|
|
|
self.is_random = False # 随机选择角色
|
|
|
@@ -324,11 +325,9 @@ class Menu:
|
|
|
text_c = f"继续游戏 (关卡: {lvl}-{stage}) \n (难度: {self.diff_dic[last['difficulty']]}; 英雄: {self.hero_dic[last['rouge_hero']]})"
|
|
|
self.buttons.append(PygameButton(self.screen, text_c, 0.5, 0.44, 18, "#e1bd48", action=lambda: self._continue_game(last), is_bold=True, bg_alpha=191))
|
|
|
# 任务系统
|
|
|
- self.buttons.append(
|
|
|
- PygameButton(self.screen, "任务系统", 0.16, 0.16, 24, "#e1bd48", action=self._open_task, is_bold=True, fix_shape=(120,30), bg_alpha=127))
|
|
|
+ self.buttons.append(PygameButton(self.screen, "任务系统", 0.16, 0.16, 24, "#e1bd48", action=self._open_task, is_bold=True, fix_shape=(120,30), bg_alpha=127))
|
|
|
# 陈列馆
|
|
|
- self.buttons.append(
|
|
|
- PygameButton(self.screen, "陈列馆", 0.16, 0.28, 24, "#e1bd48", action=self._open_setting, is_bold=True, fix_shape=(120,30), bg_alpha=127))
|
|
|
+ self.buttons.append(PygameButton(self.screen, "陈列馆", 0.16, 0.28, 24, "#e1bd48", action=self._open_setting, is_bold=True, fix_shape=(120,30), bg_alpha=127))
|
|
|
# 难度选择
|
|
|
last_diff = {"Easy": "Easy", "Normal": "Easy", "Hell": "Normal", "Hell+": "Hell"}
|
|
|
for diff, rel in [("Easy", 0.1), ("Normal", 0.18), ("Hell", 0.26), ("Hell+", 0.34)]:
|
|
|
@@ -433,7 +432,10 @@ class Menu:
|
|
|
|
|
|
def run(self):
|
|
|
clock = pygame.time.Clock()
|
|
|
+ spawn_timer = 0
|
|
|
while True:
|
|
|
+ dt = clock.tick(60)
|
|
|
+ spawn_timer += dt
|
|
|
for event in pygame.event.get():
|
|
|
if event.type == pygame.QUIT:
|
|
|
pygame.quit()
|
|
|
@@ -444,21 +446,43 @@ class Menu:
|
|
|
# 看看有没有按钮自己处理了这次点击
|
|
|
if not any(btn.bg_rect.collidepoint(event.pos) for btn in self.buttons):
|
|
|
sound_player.play("uiFail")
|
|
|
- # 先画背景
|
|
|
- # self.screen.fill((30,30,30))
|
|
|
+ # 随机生成新粒子: 每200ms生成一个
|
|
|
+ if spawn_timer > 200:
|
|
|
+ spawn_timer = 0
|
|
|
+ x = random.randint(0, self.screen.get_width())
|
|
|
+ y = self.screen.get_height() + 10
|
|
|
+ self.particles.append(Particle(x, y))
|
|
|
+ # 更新和过滤粒子
|
|
|
+ new_particles = []
|
|
|
+ for p in self.particles:
|
|
|
+ p.update()
|
|
|
+ if p.is_alive():
|
|
|
+ new_particles.append(p)
|
|
|
+ self.particles = new_particles
|
|
|
+ # 绘制背景
|
|
|
if self.bg_image:
|
|
|
self.screen.blit(self.bg_image, (0, 0))
|
|
|
else:
|
|
|
self.screen.fill((60, 90, 60))
|
|
|
- # 再画按钮
|
|
|
+ # 绘制粒子
|
|
|
+ for p in self.particles:
|
|
|
+ p.draw(self.screen)
|
|
|
+ # 绘制按钮
|
|
|
for btn in self.buttons:
|
|
|
btn.draw()
|
|
|
pygame.display.flip()
|
|
|
- clock.tick(60)
|
|
|
|
|
|
# 读取上次存档
|
|
|
def read_continue_data(self, last_data):
|
|
|
R.continuing_game = True
|
|
|
+ self.current_hero = last_data["rouge_hero"]
|
|
|
+ with open("config.json", "r", encoding="utf-8") as json_file:
|
|
|
+ mapsetdata = json.load(json_file)
|
|
|
+ mapsetdata["map_set"] = "rogueMapSet"
|
|
|
+ mapsetdata["your_hero"] = last_data["rouge_hero"]
|
|
|
+ with open("config.json", "w", encoding="utf-8") as json_file:
|
|
|
+ json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
|
|
|
+ # ===============================================================================
|
|
|
G.CURRENT_LEVEL = last_data["current_level"]
|
|
|
R.map_json_dic = last_data["map_json_dic"]
|
|
|
R.central_mapset = last_data["central_mapset"]
|