我正在尝试用战斗制作游戏。为此,我需要遍历某个场景,直到玩家或怪物的健康值等于或小于 0。所以我设置了变量以在变量达到 0 后播放下一个场景(这是我想要循环的同一场景)。但问题是我不知道如何命名场景。这是我的代码:
def whack(self, sound):
global PL, KL, SL, BL
x, y = self._path.next_pos()
if self.overlaps(PLAYER, use_new_pos=True):
PL += 1
raise NextScene
if self.overlaps(SMOLFUNGI, use_new_pos=True):
SL -= 1
raise NextScene('the scene that is looping')
else:
self._scene.add_effect(Print(
self._screen,
SpeechBubble(sound), y, x, clear=True, delete_count=50))
if PL < 1:
raise StopApplication
if SL < 1:
raise NextScene
# Scene 7.
path = Path()
path.jump_to(podium[0], podium[1])
effects = [
Print(screen,
Box(screen.width, screen.height, uni=screen.unicode_aware),
0, 0, start_frame=1),
Print(screen, StaticRenderer(images=Grass),
x=screen.width - 140,
y=screen.height - 6,
colour=Screen.COLOUR_WHITE),
SMOLFUNGI,
PLAYER,
cross_hairs,
]
scenes.append(Scene(effects, -1))