Source Code: Simple Quiz Game
Description
Simple text quiz game.
Instructions
Use the right, left, and up arrows to choose the correct answer to the quiz question.
Source Code
SetFPS 60
LoadFont "Courier", 1, 20, 0
Type QuestionType
Question$
Answer1$
Answer2$
Answer3$
CorrectAnswer
EndType
Dim Quiz(2) As QuestionType
Quiz(1).Question$ = "What color is the sky during daytime?"
Quiz(1).Answer1$ = "Blue"
Quiz(1).Answer2$ = "Red"
Quiz(1).Answer3$ = "Purple"
Quiz(1).CorrectAnswer = 1
Quiz(2).Question$ = "What sound does a cow make?"
Quiz(2).Answer1$ = "Meow!"
Quiz(2).Answer2$ = "Pffft!"
Quiz(2).Answer3$ = "Moo!"
Quiz(2).CorrectAnswer = 3
Mode = 1
QuestionAsk = 1
Do
Cls 0
If Mode = 1
Print "Question: " + Quiz(QuestionAsk).Question$
Print ""
Print "Left Key : " + Quiz(QuestionAsk).Answer1$
Print "Right Key : " + Quiz(QuestionAsk).Answer2$
Print "Up Key : " + Quiz(QuestionAsk).Answer3$
Answer = 0
If LeftKey() Then Answer = 1
If RightKey() Then Answer = 2
If UpKey() Then Answer = 3
If Answer > 0 Then Mode = 2
FlushKeys
ElseIf Mode = 2
If Quiz(QuestionAsk).CorrectAnswer = Answer
Print "Congratuations! That is correct!"
Else
Print "Sorry, yer wrong!"
EndIf
Print ""
Print "Press Space to Continue"
If SpaceKey()
QuestionAsk = RndRange( 1, GetArrayElements( Quiz(), 1 ) )
Mode = 1
FlushKeys
EndIf
EndIf
Sync
Loop
| Categories: Source Code : Game Source Code |