如何在光线追踪迷宫之前运行动画屏幕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),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,Box(screen.width,screen.height,uni=screen.unicode_aware),start_frame=1),Arrow(screen,path,_speak(screen,"Welcome to The kingdom of Boletus!",centre,30),"My name is Aristotle",podium,110),"Let me tell you the story of the first king of Boletus...",180),]
scenes.append(Scene(effects))

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

effects = [
 Print(screen,StaticRenderer(images=flag),colour=Screen.COLOUR_BLACK),StaticRenderer(images=fungus),StaticRenderer(images=KING),"King (insert name here) was a mighty king",10),colour=Screen.COLOUR_BLACK,start_frame=55),"He united the Todestols and the Marshroms under one flag",80),colour=Screen.COLOUR_WHITE,start_frame=75),"The peace lasted for many years...",150),"However,he was very paranoid and feared that the Todestols would attack...",220),"so he made an army",290),"no- 'made' is the wrong word...",360),start_frame=410),start_frame=430),"He GREW an army...",430),"an army of FUNGI MEN!",500),"Please press <SPACE> Now.",570),-1))

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

effects = [ 
 Print(screen,"But when the peace treaty was signed,the king realised he wouldnt need his army...","So he locked away them away",70),"Many generations later,the castle was abondoned and began to crumble",130),"And the army of fungi men were found by the 8th king of Boletus...",200),270)
]
scenes.append(Scene(effects,-1))

# Scene 4.
path = Path()
path.jump_to(podium[0],"The 8th king was greedy and power hungry...","After all... he had no real power any more","The peace treaty said that each king had a little less power than the last,","so that the kingdom Could slowly become a democracy","The 8th king released his army to enforce his rule...",360)
]
scenes.append(Scene(effects,-1))

# Scene 5.
path = Path()
path.jump_to(podium[0],StaticRenderer(images=HOUSE),y=screen.height - 20,"Somewhere in the mushrom forests","in a quaint little cabin lives a mushrom person","This mushroom person is you.","You enjoy cutting down the mushrom trees that provide food for the kingdom",-1))

# Scene 6.
path = Path()
path.jump_to(podium[0],"This is your charcter",PLAYER,"press → to move to your right,and ← to move to your left","Click ↑ to jump","yeh... thats about it. no more tutorial stuff...",-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 == "ma​​in": 游戏状态 = 游戏状态() 为真: 尝试: Screen.wrapper(demo,catch_interrupt=False,arguments=[game_state]) sys.exit(0) 除了 ResizeScreenError: 通过

解决方法

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