问题的背景信息:我正在编写一个文本冒险游戏,玩家可以在每个交叉点/问题处选择多条路径。
问题:我试图使用另一条路径中的变量,这可能没有被调用过。无论如何在调用此变量之前或跳过一行代码?
这是我正在讨论的代码部分
38 input "What do you do? 'A' to continue, 'B' to run away" , BAB$
39 if BAB$ == "A" then
40 if BCP$ == "B" then
41 print "The hunters see you return"
42 print "When they ask if you found the prisoner, you respond by saying that you havent seen him"
43 print "The hunters decide that this venture isnt worth it, and decide to leave, taking you with them"
44 wait 30
45 print "You escape shortly after the rest of the group leaves the area"
46 print "You are now a free man"
47 wait 200
48 clear
49 cls
50 goto 100
51 else
52 goto 55
53 endif
对我的措辞有任何疑问吗?请问!
答案 0 :(得分:1)
这个问题的最简单答案是在程序开始时初始化变量:
BAB$ = ""
BCP$ = ""
这样,当您点击第40行时,BCP $的值将为“”或具有其他值。