I';我在vb6中编程了一个游戏界面,在那里我们可以输入方向和位置变化,游戏继续
我正在尝试制作一个文本游戏,用户在开始时处于默认位置,然后他可以选择移动的方向和新位置。目标是在3个不同的位置找到3个晶体,并转到需要3个晶体进入的最后一个位置 请参考随附的地图以便更好地理解(我们从魔法森林开始) 我的问题是在一开始,如果我从魔法森林到西部(位置2),那里的一切都很完美。当我从那里回来时,即从位置2往东,它会回到魔法森林。同时,如果我去北/南/东/西,它保持在同一位置。 另外,如果从一开始我直接去北/南/东,它会去那里,但在那之后,我尝试移动的任何地方它都不会移动(保持在相同的位置),同时给出水晶的if命令也不会起作用 当我从起始位置向北/向南/向东移动时,如果命令起作用,就好像不起作用一样 还是从西方卷土重来 附言:我添加了一些额外的代码试图解决这个问题。另外,我只是一个新的程序员,所以请容忍我:|I';我在vb6中编程了一个游戏界面,在那里我们可以输入方向和位置变化,游戏继续,vb6,Vb6,我正在尝试制作一个文本游戏,用户在开始时处于默认位置,然后他可以选择移动的方向和新位置。目标是在3个不同的位置找到3个晶体,并转到需要3个晶体进入的最后一个位置 请参考随附的地图以便更好地理解(我们从魔法森林开始) 我的问题是在一开始,如果我从魔法森林到西部(位置2),那里的一切都很完美。当我从那里回来时,即从位置2往东,它会回到魔法森林。同时,如果我去北/南/东/西,它保持在同一位置。 另外,如果从一开始我直接去北/南/东,它会去那里,但在那之后,我尝试移动的任何地方它都不会移动(保持在相同的
Private子命令1\u Click()
`Dim RunGame、Location1、Location2、Location3、`Location4、Location5、Location6、Location7、Location8、Location9、CurrentLocation作为字符串
作为整数的暗淡晶体
晶体=0
RunGame=“”
Location1=“魔法森林”
地点2=“死亡之桥”
Location3=“巫师城堡”
Location4=“不死生物的沼泽”
Location5=“快速的沙子”
Location6=“绝望的沼泽”
Location7=“精灵瀑布”
Location8=“吸血鬼湾”
位置9=“狼人山”
当前位置=位置1
做
做
RunGame=UCase(InputBox(“下一步要向哪个方向走?”)
如果(RunGame=“北”或RunGame=“南”或RunGame=“西”或RunGame=“东”或RunGame=“退出”),则
打印“真”
其他的
MsgBox(“无效条目。请重试!”)
如果结束
如果RunGame=“退出”,则
MsgBox(“游戏结束了,再见!”)
终点
如果结束
循环直到(RunGame=“北”或RunGame=“南”或RunGame=“东”或RunGame=“西”或RunGame=“退出”)
做
如果CurrentLocation=Location1且RunGame=“NORTH”,则CurrentLocation=Location4
如果CurrentLocation=Location1且RunGame=“SOUTH”,则CurrentLocation=Location8
如果CurrentLocation=Location1且RunGame=“WEST”,则CurrentLocation=Location2
如果CurrentLocation=Location1且RunGame=“EAST”,则CurrentLocation=Location6
打印“当前位置为:”;当前位置
做
RunGame=UCase(InputBox(“下一步要向哪个方向走?”)
如果(RunGame=“北”或RunGame=“南”或RunGame=“西”或RunGame=“东”或RunGame=“退出”),则
打印“真”
其他的
MsgBox(“无效条目。请重试!”)
如果结束
如果RunGame=“退出”,则
MsgBox(“游戏结束了,再见!”)
终点
如果结束
循环直到(RunGame=“北”或RunGame=“南”或RunGame=“东”或RunGame=“西”或RunGame=“退出”)
循环直到(CurrentLocation=Location2或CurrentLocation=Location4或CurrentLocation=Location6或CurrentLocation=Location8)
'
做
如果CurrentLocation=Location2且RunGame=“EAST”,则CurrentLocation=Location1
如果CurrentLocation=Location2和(RunGame=“NORTH”或RunGame=“SOUTH”),则MsgBox(“空白空间”)
如果CurrentLocation=位置2且Crystal<3且RunGame=“WEST”,则
当前位置=位置2
打印“对不起,您没有足够的晶体通过此处”
如果结束
打印“当前位置为:”;当前位置
做
RunGame=UCase(InputBox(“下一步要向哪个方向走?”)
如果(RunGame=“北”或RunGame=“南”或RunGame=“西”或RunGame=“东”或RunGame=“退出”),则
打印“真”
其他的
MsgBox(“无效条目。请重试!”)
如果结束
如果RunGame=“退出”,则
MsgBox(“游戏结束了,再见!”)
终点
如果结束
循环直到(RunGame=“北”或RunGame=“南”或RunGame=“东”或RunGame=“西”或RunGame=“退出”)
如果CurrentLocation=Location2且Crystal>=3且RunGame=“WEST”,则
当前位置=位置3
打印“祝贺你!巫师被打败了,王子获救了。你已经完成了游戏!”
如果结束
循环直到(CurrentLocation=Location1或CurrentLocation=Location3)
'
做
如果CurrentLocation=位置4,则
打印“那个闪亮的小东西是什么?等等,它是一个水晶。得到了一个水晶”
如果结束
如果CurrentLocation=Location4且RunGame=“EAST”,则
当前位置=位置4
打印“当快速的沙子将你吸入时,你无助地挣扎!”
如果结束
如果CurrentLocation=Location4和(RunGame=“NORTH”或RunGame=“WEST”),则MsgBox(“空白空间”)
如果CurrentLocation=Location4且RunGame=“SOUTH”,则CurrentLocation=Location1
打印“当前位置为:”;当前位置
做
RunGame=UCase(InputBox(“下一步要向哪个方向走?”)
如果(RunGame=“北”或RunGame=“南”或RunGame=“西”或RunGame=“东”或RunGame=“退出”),则
打印“真”
其他的
MsgBox(“无效条目。请重试!”)
如果结束
如果RunGame=“退出”,则
MsgBox(“游戏结束了,再见!”)
终点
如果结束
循环直到(RunGame=“北”
`Dim RunGame, Location1, Location2, Location3,` Location4,Location5,Location6, Location7, Location8, Location9, CurrentLocation As String
Dim Crystal As Integer
Crystal = 0
RunGame = ""
Location1 = "Enchanted Forest"
Location2 = "Bridge of Death"
Location3 = "Wizard's Castle"
Location4 = "Marsh of the Undead"
Location5 = "Sands of Quick"
Location6 = "Swamps of despair"
Location7 = "Elven Waterfall"
Location8 = "Vampire Cove"
Location9 = "Werewolf Hills"
CurrentLocation = Location1
Do
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Do
If CurrentLocation = Location1 And RunGame = "NORTH" Then CurrentLocation = Location4
If CurrentLocation = Location1 And RunGame = "SOUTH" Then CurrentLocation = Location8
If CurrentLocation = Location1 And RunGame = "WEST" Then CurrentLocation = Location2
If CurrentLocation = Location1 And RunGame = "EAST" Then CurrentLocation = Location6
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location2 Or CurrentLocation = Location4 Or CurrentLocation = Location6 Or CurrentLocation = Location8)
'
Do
If CurrentLocation = Location2 And RunGame = "EAST" Then CurrentLocation = Location1
If CurrentLocation = Location2 And (RunGame = "NORTH" Or RunGame = "SOUTH") Then MsgBox ("Empty Space")
If CurrentLocation = Location2 And Crystal < 3 And RunGame = "WEST" Then
CurrentLocation = Location2
Print "Sorry you Don't have enough crystals to pass through here"
End If
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
If CurrentLocation = Location2 And Crystal >= 3 And RunGame = "WEST" Then
CurrentLocation = Location3
Print "Congratulations! The Wizard have been defeated and The Prince has been rescued. You have finished the game!"
End If
Loop Until (CurrentLocation = Location1 Or CurrentLocation = Location3)
'
Do
If CurrentLocation = Location4 Then
Print "What's that shiny little thing? Wait It's a crystal. Obtained a crystal"
End If
If CurrentLocation = Location4 And RunGame = "EAST" Then
CurrentLocation = Location4
Print "You struggle helplessly as the quick sand sucks you in!"
End If
If CurrentLocation = Location4 And (RunGame = "NORTH" Or RunGame = "WEST") Then MsgBox ("Empty Space")
If CurrentLocation = Location4 And RunGame = "SOUTH" Then CurrentLocation = Location1
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location1)
'
Do
If CurrentLocation = Location6 And RunGame = "EAST" Then MsgBox ("Empty Space")
If CurrentLocation = Location6 And RunGame = "NORTH" Then
CurrentLocation = Location6
Print "You struggle helplessly as the quick sand sucks you in!"
End If
If CurrentLocation = Location6 And RunGame = "WEST" Then CurrentLocation = Location1
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location1 Or CurrentLocation = Location7)
'
Do
If CurrentLocation = Location7 Then
Print "What's that shiny little thing? Wait, It's a crystal. Obtained a crystal"
End If
If CurrentLocation = Location7 And RunGame = "NORTH" Then CurrentLocation = Location6
If CurrentLocation = Location7 And (RunGame = "EAST" Or RunGame = "SOUTH" Or RunGame = "WEST") Then MsgBox ("Empty Space")
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location6)
'
Do
If CurrentLocation = Location8 And RunGame = "NORTH" Then CurrentLocation = Location1
If CurrentLocation = Location8 And (RunGame = "EAST" Or RunGame = "WEST") Then MsgBox ("Empty Space")
If CurrentLocation = Location8 And RunGame = "SOUTH" Then CurrentLocation = Location9
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location1 Or CurrentLocation = Location9)
'
Do
If CurrentLocation = Location9 Then
Print "What's that shiny little thing? Wait, It's a crystal. Obtained a crystal"
End If
If CurrentLocation = Location9 And RunGame = "NORTH" Then CurrentLocation = Location8
If CurrentLocation = Location9 And (RunGame = "EAST" Or RunGame = "SOUTH" Or RunGame = "WEST") Then MsgBox ("Empty Space")
Print "CurrentLocation is: "; CurrentLocation
Do
RunGame = UCase(InputBox("In Which direction do you want to go next?"))
If (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "WEST" Or RunGame = "EAST" Or RunGame = "QUIT") Then
Print "True"
Else
MsgBox ("Invalid Entry. Please Re-try!")
End If
If RunGame = "QUIT" Then
MsgBox ("Game is Ending. GoodBye!")
End
End If
Loop Until (RunGame = "NORTH" Or RunGame = "SOUTH" Or RunGame = "EAST" Or RunGame = "WEST" Or RunGame = "QUIT")
Loop Until (CurrentLocation = Location8)
'
Loop Until RunGame = "QUIT"
End Sub
Dim locations(3,3) as Integer
locations(0,0) = "Enchanted Forest"
...etc.
Dim cLocX as Integer, cLocY as Integer
MsgBox locations(cLocX, cLocY)