增加撑杆跳音效

This commit is contained in:
星外之神 2022-05-10 22:38:05 +08:00
parent 8d6d010933
commit 02edab3516
6 changed files with 18 additions and 10 deletions

View File

@ -14,7 +14,8 @@
{"time":7000, "map_y":4, "name":"ScreenDoorZombie"}, {"time":7000, "map_y":4, "name":"ScreenDoorZombie"},
{"time":8000, "map_y":4, "name":"ScreenDoorZombie"}, {"time":8000, "map_y":4, "name":"ScreenDoorZombie"},
{"time":0, "map_y":1, "name":"NewspaperZombie"}, {"time":0, "map_y":1, "name":"NewspaperZombie"},
{"time":0, "map_y":0, "name":"PoleVaultingZombie"}, {"time":3000, "map_y":0, "name":"PoleVaultingZombie"},
{"time":0, "map_y":0, "name":"FootballZombie"},
{"time":0, "map_y":2, "name":"ConeheadDuckyTubeZombie"}, {"time":0, "map_y":2, "name":"ConeheadDuckyTubeZombie"},
{"time":80000, "map_y":2, "name":"ConeheadDuckyTubeZombie"} {"time":80000, "map_y":2, "name":"ConeheadDuckyTubeZombie"}
] ]

Binary file not shown.

View File

@ -511,10 +511,10 @@ class WallNut(Plant):
self.loadFrames(self.cracked2_frames, cracked2_frames_name, 1) self.loadFrames(self.cracked2_frames, cracked2_frames_name, 1)
def idling(self): def idling(self):
if not self.cracked1 and self.health <= c.WALLNUT_CRACKED1_HEALTH: if (not self.cracked1) and self.health <= c.WALLNUT_CRACKED1_HEALTH:
self.changeFrames(self.cracked1_frames) self.changeFrames(self.cracked1_frames)
self.cracked1 = True self.cracked1 = True
elif not self.cracked2 and self.health <= c.WALLNUT_CRACKED2_HEALTH: elif (not self.cracked2) and self.health <= c.WALLNUT_CRACKED2_HEALTH:
self.changeFrames(self.cracked2_frames) self.changeFrames(self.cracked2_frames)
self.cracked2 = True self.cracked2 = True

View File

@ -884,11 +884,14 @@ class PoleVaultingZombie(Zombie):
self.frames = self.walk_before_jump_frames self.frames = self.walk_before_jump_frames
def setJump(self, successfullyJumped): def setJump(self, successfullyJumped, jumpX):
if not self.jumping: if not self.jumping:
self.jumping = True self.jumping = True
self.changeFrames(self.jump_frames) self.changeFrames(self.jump_frames)
self.successfullyJumped = successfullyJumped self.successfullyJumped = successfullyJumped
self.jumpX = jumpX
# 播放跳跃音效
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "polevaultjump.ogg")).play()
def animation(self): def animation(self):
if self.state == c.FREEZE: if self.state == c.FREEZE:
@ -898,7 +901,10 @@ class PoleVaultingZombie(Zombie):
if (self.current_time - self.animate_timer) > (self.animate_interval * self.getTimeRatio()): if (self.current_time - self.animate_timer) > (self.animate_interval * self.getTimeRatio()):
self.frame_index += 1 self.frame_index += 1
if self.jumping and (not self.jumped): if self.jumping and (not self.jumped):
self.rect.x -= 5 if self.successfullyJumped:
self.rect.x -= 5
else:
self.rect.x -= 1
if self.frame_index >= self.frame_num: if self.frame_index >= self.frame_num:
if self.state == c.DIE: if self.state == c.DIE:
self.kill() self.kill()
@ -907,7 +913,7 @@ class PoleVaultingZombie(Zombie):
if self.jumping and (not self.jumped): if self.jumping and (not self.jumped):
self.changeFrames(self.walk_frames) self.changeFrames(self.walk_frames)
if self.successfullyJumped: if self.successfullyJumped:
self.rect.x -= c.GRID_X_SIZE * 1.3 self.rect.centerx = self.jumpX
self.jumped = True self.jumped = True
self.speed = 1.04 self.speed = 1.04
self.animate_timer = self.current_time self.animate_timer = self.current_time

View File

@ -166,7 +166,7 @@ PANEL_Y_INTERNAL = 73
PANEL_X_INTERNAL = 53 PANEL_X_INTERNAL = 53
BAR_CARD_X_INTERNAL = 51 BAR_CARD_X_INTERNAL = 51
CARD_MAX_NUM = 10 # 这里以后可以增加解锁功能从最初的6格逐渐解锁到10格 CARD_MAX_NUM = 10 # 这里以后可以增加解锁功能从最初的6格逐渐解锁到10格
CARD_LIST_NUM = 0#CARD_MAX_NUM CARD_LIST_NUM = CARD_MAX_NUM
# 所选植物信息索引 # 所选植物信息索引
PLANT_NAME_INDEX = 0 PLANT_NAME_INDEX = 0

View File

@ -1070,10 +1070,11 @@ class Level(tool.State):
# 撑杆跳的特殊情况 # 撑杆跳的特殊情况
if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped): if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped):
map_x, map_y = self.map.getMapIndex(targetPlant.rect.centerx, targetPlant.rect.bottom) map_x, map_y = self.map.getMapIndex(targetPlant.rect.centerx, targetPlant.rect.bottom)
jumpX = targetPlant.rect.x - c.GRID_X_SIZE * 0.7
if c.TALLNUT in self.map.map[map_y][map_x][c.MAP_PLANT]: if c.TALLNUT in self.map.map[map_y][map_x][c.MAP_PLANT]:
zombie.setJump(False) zombie.setJump(False, jumpX)
else: else:
zombie.setJump(True) zombie.setJump(True, jumpX)
continue continue
if targetPlant.name == c.WALLNUTBOWLING: if targetPlant.name == c.WALLNUTBOWLING:
@ -1279,7 +1280,7 @@ class Level(tool.State):
if plant.canAttack(zombie): if plant.canAttack(zombie):
plant.setAttack(zombie, self.zombie_groups[i]) plant.setAttack(zombie, self.zombie_groups[i])
break break
elif plant.name in {c.WALLNUTBOWLING, c.REDWALLNUTBOWLING}: elif plant.name in {c.WALLNUTBOWLING, c.REDWALLNUTBOWLING, c.WALLNUT, c.TALLNUT}:
pass pass
else: else:
can_attack = False can_attack = False