在我使用了我的子程序 2 - 4 次之后。一条消息说"Press any key to continue..."



我正在使用Small Basic,我对编程相当陌生。下面是我的子程序:

Sub MoneyClasses
    If CurrentJob = "Cleaner" Then
        Money = Money + 1
    ElseIf CurrentJob = "Farmer" Then
        Money = Money + 3
    ElseIf CurrentJob = "Factory Worker" Then
        Money = Money + 5
    ElseIf CurrentJob = "Teacher" Then
        Money = Money + 10
    ElseIf CurrentJob = "Shopkeeper" Then
        Money = Money + 20
    ElseIf CurrentJob = "Doctor" Then
        Money = Money + 30
    ElseIf CurrentJob = "Soldier" Then
        Money = Money + 25
    ElseIf CurrentJob = "Officer" Then
        Money = Money + 45
    ElseIf CurrentJob = "General" Then
        Money = Money + 100
    ElseIf CurrentJob = "Supreme Leader" Then
        Money = Money + 10000
    EndIf
EndSub 
Sub Work1
    MoneyClasses()
    Energy = Energy - 10
EndSub
Sub Sleep1
    Energy = Energy + 10
    Money = Money - 1
EndSub
Sub Stats1
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("You have " + Energy +" Energy.")
    TextWindow.WriteLine("You have " + Money +" Won.")
    TextWindow.Write(" ")
    TextWindow.Read()
EndSub
Sub Menu
    TextWindow.WriteLine("Current Job = " + CurrentJob + "")
    TextWindow.WriteLine("Name = " + Name + "")
    TextWindow.WriteLine("1 - Work")
    TextWindow.WriteLine("2 - Sleep")
    TextWindow.WriteLine("3 - Show Stats")
    TextWindow.WriteLine(" ")
    TextWindow.Write("What to do?: ")
    PlayerInput = TextWindow.Read()
    TextWindow.Clear()
EndSub

是啊,我完全不知道怎么了。这可能是个小错误。我还应该提到的是,游戏还没有完全完成,我的意思是我还没有完成一半。

"Press an key to continue"是程序完成时弹出的消息。我最好的猜测是,在调用子例程之后,程序已经完成了两次广告。如果没有循环机制使球滚动,程序将退出。

我建议在子例程调用之前在顶部放置一个标签,并在底部放置一个goto跳转到顶部。像这样:

top:
'Your Program code
Goto top 

相关内容

  • 没有找到相关文章

最新更新