如何 运行 光线追踪迷宫前的动画屏幕(python asciimatics)

how to run an animation screen before a ray-tracing maze (python asciimatics)

我正在研究 asciimatics,但是我是 python 的新手,并不完全理解 asciimatics。我正在尝试 运行 在 运行 动画(游戏的背景故事)之后的光线投射示例代码,但它只是 运行 开始时的光线投射迷宫.这是我的代码。请帮忙!

#scene title-screen
scenes = []
centre = (screen.width // 2, screen.height // 2)
podium = (8, 5)

if screen.width != 140 or screen.height != 32:
    effects = [
        Print(screen, FigletText("Resize to 140x32"),
              y=screen.height//2-3),
    ]
else:
    effects = [
     Print(screen, StaticRenderer(images=tree),
        x=screen.width - 30,
        y=screen.height - 15,
          colour=Screen.COLOUR_WHITE),
    
    Rain(screen, 99999),
    Print(screen, FigletText("Mushroom Quest", "slant"),
        y=screen.height//3-3),
    Print(screen, FigletText("Press space to play", "term"),
        y=2 * screen.height//3-3),
]
scenes.append(Scene(effects, -1))

# Scene 1.
path = Path()
path.jump_to(-20, centre[1])
path.move_straight_to(centre[0], centre[1], 10)
path.wait(30)
path.move_straight_to(podium[0], podium[1], 10)
path.wait(100)

effects = [  
 Print(screen, StaticRenderer(images=Map),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_WHITE),
 Print(screen,
    Box(screen.width, screen.height, uni=screen.unicode_aware),
    0, 0, start_frame=1),
    
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "Welcome to The kingdom of Boletus!", centre, 30),
    _speak(screen, "My name is Aristotle", podium, 110),
    _speak(screen,
           "Let me tell you the story of the first king of Boletus...", podium, 180),
]
scenes.append(Scene(effects))

# Scene 2.
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=flag),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_BLACK),
 
      Print(screen, StaticRenderer(images=fungus),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_BLACK),
 
 Print(screen, StaticRenderer(images=KING),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_WHITE),
    
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "King (insert name here) was a mighty king", podium, 10),
 Print(screen, StaticRenderer(images=KING),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_BLACK,start_frame=55),
    _speak(screen, "He united the Todestols and the Marshroms under one flag", podium, 80),
 Print(screen, StaticRenderer(images=flag),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_WHITE,start_frame=75),
    _speak(screen, "The peace lasted for many years...",
           podium, 150),
    _speak(screen, "However, he was very paranoid and feared that the Todestols would attack...", podium, 220),
    _speak(screen, "so he made an army", podium, 290),
    _speak(screen, "no- 'made' is the wrong word...", podium, 360),
 Print(screen, StaticRenderer(images=flag),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_BLACK,start_frame=410),
 Print(screen, StaticRenderer(images=fungus),
    x=screen.width - 65,
    y=screen.height - 25,
      colour=Screen.COLOUR_WHITE,start_frame=430),
    _speak(screen, "He GREW an army...",
           podium, 430),
    _speak(screen, "an army of FUNGI MEN!",
           podium, 500),
    _speak(screen, "Please press <SPACE> now.", podium, 570),
]
scenes.append(Scene(effects, -1))

# Scene 3.
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),
 
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "But when the peace treaty was signed, the king realised he wouldnt need his army...", podium, 10),
    _speak(screen, "So he locked away them away",
           podium, 70),
    _speak(screen, "Many generations later, the castle was abondoned and began to crumble", podium, 130),
    _speak(screen, "And the army of fungi men were found by the 8th king of Boletus...", podium,
           200),
    _speak(screen, "Please press <SPACE> now.", podium, 270)
]
scenes.append(Scene(effects, -1))

# Scene 4.
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),
 
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "The 8th king was greedy and power hungry...", podium, 10),
    _speak(screen, "After all... he had no real power any more", podium,
           80),
    _speak(screen, "The peace treaty said that each king had a little less power than the last,", podium, 150),
    _speak(screen, "so that the kingdom could slowly become a democracy", podium,
           220),
    _speak(screen, "The 8th king released his army to enforce his rule...", podium, 290),
    _speak(screen, "Please press <SPACE> now.", podium, 360)
]
scenes.append(Scene(effects, -1))

# Scene 5.
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=HOUSE),
    x=screen.width - 65,
    y=screen.height - 20,
      colour=Screen.COLOUR_WHITE),
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "Somewhere in the mushrom forests", podium, 10),
    _speak(screen, "in a quaint little cabin lives a mushrom person", podium, 70),
    _speak(screen, "This mushroom person is you.", podium, 130),
    _speak(screen, "You enjoy cutting down the mushrom trees that provide food for the kingdom", podium,
           200),
    _speak(screen, "Please press <SPACE> now.", podium, 270)
]
scenes.append(Scene(effects, -1))

# Scene 6.
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),
 
    Arrow(screen, path, colour=Screen.COLOUR_WHITE),
    _speak(screen, "This is your charcter", podium, 10),
    PLAYER,
    _speak(screen, "press → to move to your right, and ← to move to your left", podium, 80),
    _speak(screen, "Click ↑ to jump", podium, 150),
    _speak(screen, "yeh... thats about it. no more tutorial stuff...", podium, 220),
    _speak(screen, "Please press <SPACE> now.", podium, 360)
]
scenes.append(Scene(effects, -1))

# Scene 7.
path = Path()
path.jump_to(podium[0], podium[1])

effects = [
screen.play([GameController(screen, game_state)], stop_on_resize=True)
]
scenes.append(Scene(effects, -1))

screen.play(scenes, stop_on_resize=True)

if name == "main": game_state = 游戏状态() 而真实的: 尝试: Screen.wrapper(演示,catch_interrupt=假,参数=[game_state]) sys.exit(0) 除了 ResizeScreenError: 通过

问题是您在为 GameController 设置效果时调用了 screen.play。不要那样做。最后调用一次play即可。