代码拉取完成,页面将自动刷新
import pygame
class Traps:
def __init__(self, x, y, trap_type, if_visible):
self.type = trap_type # type 0: damage, type 1: freeze
self.if_v = if_visible
self.coord_x = x
self.coord_y = y
self.triggered = False
if self.type == 0:
self.image_armed = pygame.image.load(r"image/armed_explode_trap.png")
self.image_triggered = pygame.image.load(r"image/broken_explode_trap.png")
elif self.type == 1:
self.image_armed = pygame.image.load(r"image/armed_freeze_trap.png")
self.image_triggered = pygame.image.load(r"image/broken_freeze_trap.png")
if not self.if_v:
self.image_armed = pygame.image.load(r"image/blank_trap.png")
self.image = self.image_armed
# trigger current trap
def trigger(self):
if ~self.triggered:
self.triggered = True
if self.type == 0:
sound = pygame.mixer.Sound("sound/sound_effect/explode_trap.mp3")
else:
sound = pygame.mixer.Sound("sound/sound_effect/freeze.wav")
sound.set_volume(1)
sound.play()
self.image = self.image_triggered
# judge if the trap is still not triggered
def functioning(self):
if self.triggered:
return False
else:
return True
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。