小的基本测验,顺序相反

  • 本文关键字:顺序 smallbasic
  • 更新时间 :
  • 英文 :


我正在为学校创建一个小型基本测验,我使用了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'

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

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

您还可以使用标志来确保图形窗口不会在单击某些内容的情况下更改。

相关内容

  • 没有找到相关文章

最新更新