小基本测验,按相反顺序排列

时间:2016-01-19 16:54:38

标签: smallbasic

我正在为学校创建一个Small Basic Quiz,我使用了GraphicsWindow,所以我创建了按钮。我的工作正常,直到我添加其他问题,因为它开始以相反的顺序显示它们。

这是我的代码:

GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.CanResize = "True"
GraphicsWindow.Height = 650
GraphicsWindow.Width = 1200
GraphicsWindow.Top = 25
GraphicsWindow.Left = 50
GraphicsWindow.Title = "Advanced Computer Quiz
Goto Q1

'End Of GraphicWindow Settings'


'Start Of Game Varibles Settings'


'End Of Game Varibles Settings'


'Start Of Question One'

Q1:
GraphicsWindow.Clear()
GraphicsWindow.DrawText(1, 1, "Q.1")
GraphicsWindow.DrawText(1, 60, "What does CPU stand for?")
GraphicsWindow.drawtext(1, 120, "A. Computer Prossesing Unit   B. Central Prossesing Unit   C. Core Prossesing Unit")

Button_A = Controls.AddButton(" A ",7 ,160)
Button_B = Controls.AddButton(" B ",42 ,160)
Button_C = Controls.AddButton(" C ",77 ,160)

Controls.ButtonClicked = ButtonClicked_Input_Q1

Sub ButtonClicked_Input_Q1
  LastButtonClicked = Controls.LastClickedButton

  If LastButtonClicked = Button_A Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q2

  ElseIf LastButtonClicked = Button_B Then
    GraphicsWindow.ShowMessage(" Correct! ", " Answer ")
    Score = Score + 1 
    Goto Q2

  ElseIf LastButtonClicked = Button_C Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q2

  EndIf
EndSub

' End Of Question One'


' Start Of Question Two'

Q2:
GraphicsWindow.Clear()
GraphicsWindow.DrawText(1, 1, "Q.2")
GraphicsWindow.DrawText(1, 60, "What does RAM stand for?")
GraphicsWindow.drawtext(1, 120, "A. Random Access Memory   B. Relative Atomic Mass   C. Random Active Movement")

Button_A = Controls.AddButton(" A ",7 ,160)
Button_B = Controls.AddButton(" B ",42 ,160)
Button_C = Controls.AddButton(" C ",77 ,160)

Controls.ButtonClicked = ButtonClicked_Input_Q2

Sub ButtonClicked_Input_Q2
  LastButtonClicked = Controls.LastClickedButton

  If LastButtonClicked = Button_A Then
    GraphicsWindow.ShowMessage(" Correct! ", " Answer ")
    Score = Score + 1
    Goto Q3

  ElseIf LastButtonClicked = Button_B Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q3

  ElseIf LastButtonClicked = Button_C Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q3

  EndIf
EndSub

'End Of Question Two'


'Start Of Question Three'

Q3:
GraphicsWindow.Clear()
GraphicsWindow.DrawText(1, 1, "Q.3")
GraphicsWindow.DrawText(1, 60, "What are the Three types of Networks?")
GraphicsWindow.drawtext(1, 120, "A. Lan Dan Wan   B. Lan San Wan   C. Lan Gan Wan")

Button_A = Controls.AddButton(" A ",7 ,160)
Button_B = Controls.AddButton(" B ",42 ,160)
Button_C = Controls.AddButton(" C ",77 ,160)

Controls.ButtonClicked = ButtonClicked_Input_Q3

Sub ButtonClicked_Input_Q3
  LastButtonClicked = Controls.LastClickedButton

  If LastButtonClicked = Button_A Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q4

  ElseIf LastButtonClicked = Button_B Then
    GraphicsWindow.ShowMessage(" Correct! ", " Answer ")
    Score = Score + 1
    Goto Q4

  ElseIf LastButtonClicked = Button_C Then
    GraphicsWindow.ShowMessage(" Incorrect ", " Answer ")
    Goto Q4

  EndIf
EndSub

'End Of Question Three'

2 个答案:

答案 0 :(得分:1)

两个问题。首先,你不能在子程序中使用goto。这样做是为了不能继续下一个问题。第二个问题是你在每个问题之后都没有暂停,所以在第一个问题之后它就不会停止。它只会吹到最后。以下是修改后的工作代码: TDD527

(使用任务栏上的'导入'按钮,然后输入TDD527)

答案 1 :(得分:0)

您还可以使用标记来确保图形窗口无需单击即可更改。