1

我正在使用 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

是的,我完全不知道出了什么问题。这可能是一个小错误。我还应该提到游戏还没有完全完成,我的意思是我还没有完成一半。只是做“基础”。

4

1 回答 1

0

“Press an key to continue”是程序完成时弹出的消息。我最好的猜测是,在你调用你的子程序两次之后,你的程序就完成了。如果没有循环机制来让球滚动,程序就会退出。

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

top:
'Your Program code
Goto top 
于 2017-04-03T19:11:09.330 回答