命名ascimatics场景



我正试图制作一款打斗游戏。要做到这一点,我需要在某个场景中循环,直到玩家或怪物的生命值为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))

它只是Scene对象上的一个参数。有关如何使用它们的说明,请阅读文档中的相关部分(https://asciimatics.readthedocs.io/en/stable/widgets.html#exceptions)。

关键示例如下。

# Given this scene list...
scenes = [
Scene([ListView(screen, contacts)], -1, name="Main"),
Scene([ContactView(screen, contacts)], -1, name="Edit Contact")
]
screen.play(scenes)
# You can use this code to move back to the first scene at any time...
raise NextScene("Main")

相关内容

  • 没有找到相关文章

最新更新