修复选卡模式下点击菜单会闪退的bug;更改封装
This commit is contained in:
parent
be5309f328
commit
7164dd3beb
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@ -548,7 +548,7 @@ class CherryBomb(Plant):
|
||||
self.explode_x_range = c.GRID_X_SIZE * 1.5
|
||||
|
||||
def setBoom(self):
|
||||
frame = tool.GFX[c.CHERRY_BOOM_IMAGE]
|
||||
frame = tool.GFX[c.BOOM_IMAGE]
|
||||
rect = frame.get_rect()
|
||||
width, height = rect.w, rect.h
|
||||
|
||||
@ -1232,16 +1232,12 @@ class RedWallNutBowling(Plant):
|
||||
|
||||
def loadImages(self, name, scale):
|
||||
self.idle_frames = []
|
||||
self.explode_frames = []
|
||||
self.loadFrames(self.idle_frames, name, 1)
|
||||
|
||||
idle_name = name
|
||||
explode_name = name + 'Explode'
|
||||
|
||||
frame_list = [self.idle_frames, self.explode_frames]
|
||||
name_list = [idle_name, explode_name]
|
||||
|
||||
for i, name in enumerate(name_list):
|
||||
self.loadFrames(frame_list[i], name, 1, c.WHITE)
|
||||
frame = tool.GFX[c.BOOM_IMAGE]
|
||||
rect = frame.get_rect()
|
||||
image = tool.get_image(frame, 0, 0, rect.w, rect.h)
|
||||
self.explode_frames = (image, )
|
||||
|
||||
self.frames = self.idle_frames
|
||||
|
||||
|
||||
@ -244,6 +244,7 @@ NON_PLANT_OBJECTS = {
|
||||
|
||||
# 植物相关信息
|
||||
PLANT_IMAGE_RECT = 'plant_image_rect'
|
||||
BOOM_IMAGE = 'Boom'
|
||||
|
||||
# 植物卡片信息汇总(包括植物名称, 卡片名称, 阳光, 冷却时间)
|
||||
PLANT_CARD_INFO = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间)
|
||||
@ -420,7 +421,7 @@ PLANT_COLOR_KEY_WHITE = {
|
||||
JALAPENO, SCAREDYSHROOM,
|
||||
SUNSHROOM, ICESHROOM,
|
||||
HYPNOSHROOM, SQUASH,
|
||||
WALLNUTBOWLING, REDWALLNUTBOWLING,
|
||||
WALLNUTBOWLING,
|
||||
}
|
||||
|
||||
# 直接水生植物
|
||||
|
||||
@ -1506,7 +1506,16 @@ class Level(tool.State):
|
||||
# 画僵尸头
|
||||
surface.blit(self.level_progress_zombie_head_image, self.level_progress_zombie_head_image_rect)
|
||||
|
||||
def showCurrentVolumeImage(self, surface):
|
||||
def showAllContentOfMenu(self, surface):
|
||||
# 绘制不可变内容
|
||||
surface.blit(self.big_menu, self.big_menu_rect)
|
||||
surface.blit(self.return_button, self.return_button_rect)
|
||||
surface.blit(self.restart_button, self.restart_button_rect)
|
||||
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
||||
surface.blit(self.sound_volume_minus_button, self.sound_volume_minus_button_rect)
|
||||
surface.blit(self.sound_volume_plus_button, self.sound_volume_plus_button_rect)
|
||||
|
||||
# 显示当前音量
|
||||
# 由于音量可变,因此这一内容不能在一开始就结束加载,而应当不断刷新不断显示
|
||||
font = pg.font.Font(c.FONT_PATH, 30)
|
||||
volume_tips = font.render(f"音量:{round(self.game_info[c.SOUND_VOLUME]*100):3}%", True, c.LIGHTGRAY)
|
||||
@ -1523,11 +1532,7 @@ class Level(tool.State):
|
||||
# 画小菜单
|
||||
surface.blit(self.little_menu, self.little_menu_rect)
|
||||
if self.showLittleMenu:
|
||||
surface.blit(self.big_menu, self.big_menu_rect)
|
||||
surface.blit(self.return_button, self.return_button_rect)
|
||||
surface.blit(self.restart_button, self.restart_button_rect)
|
||||
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
||||
self.showCurrentVolumeImage()
|
||||
self.showAllContentOfMenu(surface)
|
||||
# 以后可能需要插入一个预备的状态(预览显示僵尸、返回战场)
|
||||
elif self.state == c.PLAY:
|
||||
if self.hasShovel:
|
||||
@ -1556,13 +1561,7 @@ class Level(tool.State):
|
||||
self.drawMouseShowPlus(surface)
|
||||
|
||||
if self.showLittleMenu:
|
||||
surface.blit(self.big_menu, self.big_menu_rect)
|
||||
surface.blit(self.return_button, self.return_button_rect)
|
||||
surface.blit(self.restart_button, self.restart_button_rect)
|
||||
surface.blit(self.mainMenu_button, self.mainMenu_button_rect)
|
||||
surface.blit(self.sound_volume_minus_button, self.sound_volume_minus_button_rect)
|
||||
surface.blit(self.sound_volume_plus_button, self.sound_volume_plus_button_rect)
|
||||
self.showCurrentVolumeImage(surface)
|
||||
self.showAllContentOfMenu(surface)
|
||||
|
||||
if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_AUTO:
|
||||
self.showLevelProgress(surface)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user