如何解决命名 asciimatics 场景
我正在努力制作一款有战斗力的游戏。为此,我需要遍历某个场景,直到玩家或怪物的健康值为 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),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,name="Edit Contact")
]
screen.play(scenes)
# You can use this code to move back to the first scene at any time...
raise NextScene("Main")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。