Here the modfied code:
/************************************************** **************
** **
** Name: Silviahemmet Quiz **
** Author: Arnim Wolff **
** Version: 0.1b **
** Date: 13.1.2015 **
** Interpreter: Hollywood 5.3 **
** Licence: Free **
** Function: Kleines Quiz für Freunde der Malteser **
** und um das Wissen um die Demenz **
** History: **
** **
** 0.1: (13.01.2015) **
** **
** - erste Alpha-Version **
** **
** **
************************************************** **************/
/*
** Important! Check if the used Hollywood version is at least
** version 2.0!
*/
@VERSION 2,0
/*
** Brushes
*/
@BRUSH 1, "Title.png"
@BRUSH 2, "Game.png"
/*
** Sounds
*/
@SAMPLE 1, "Good.wav"
@SAMPLE 2, "Poor.wav"
@SAMPLE 3, "True.wav"
@SAMPLE 4, "False.wav"
/*
** The display auskommentiert
*/
@DISPLAY {Width = 640, Height = 480, Title = "USA Quiz", Mode = "Windowed", Color = #WHITE }
/*
** Show main menu
*/
Function p_MainMenu()
Local ypos = 103
DisplayBGPic(1)
MoveBrush(1, #CENTER, #BOTTOMOUT, #CENTER, 0, 5)
SetFontColor(#BLACK)
For Local k = 0 To 319
Plot(k, 95, #BLACK)
Plot(319 - k, 250, #BLACK)
If k > 0 And k % 35 = 0
TextOut(#CENTER, ypos, text$[k \ 35])
ypos = ypos + 17
EndIf
Wait(10, #MILLISECONDS)
Next
t = 10 ; for p_DisplayText()
SetInterval(1, Function() t = Wrap(t + 1, 1, 61) p_DisplayText() EndFunction, 4000)
EndFunction
/*
** update the info text
*/
Function p_DisplayText()
Local ypos = 200
DisplayBGPic(1)
SetFontColor(#BLACK)
While text$[t] <> ""
TextOut(#CENTER, ypos, text$[t])
ypos = ypos + 17
t = t + 1
Wend
EndFunction
Function p_NextQuestion(answer)
Local n
Box(6, 123, 627, 17, IIf(answer = 1, #RED, #BLACK))
Box(6, 151, 627, 18, IIf(answer = 2, #RED, #BLACK))
Box(6, 179, 627, 17, IIf(answer = 3, #RED, #BLACK))
Box(6, 206, 627, 18, IIf(answer = 4, #RED, #BLACK))
Local numfound = False
; look for a question that has not been asked yet
While numfound = False
n = Rnd(q)
If FindStr(questions$[n], "|") <> -1 Then n = n - 1
For Local i = 0 To qc - 1
If ques = n Then Continue(2)
Next
numfound = True
Wend
; store it in the stack of already asked questions
ques[qc] = n
qc = qc + 1
TextOut(#CENTER, 102, questions$[n])
Local ans$ = SplitStr(questions$[n + 1], "|")
; randomly choose which button will hold the correct answer
correct = Rnd(4)
TextOut(#CENTER, 128, ans$[qloc[correct][0]])
TextOut(#CENTER, 156, ans$[qloc[correct][1]])
TextOut(#CENTER, 185, ans$[qloc[correct][2]])
TextOut(#CENTER, 212, ans$[qloc[correct][3]])
correct = correct + 1
EndFunction
Function p_StartGame()
gameon = True
ClearInterval(1) ; stop menu text refresh
DisableButton(1)
DisplayBGPicPart(1, 0, 96, 627, 154)
DisplayBrush(2, 0, 627)
For Local k = 2 To 5 Do EnableButton(k)
; reset question & score counters
qc = 0
score = 0
p_NextQuestion(0)
EndFunction
/*
** Check for correct answer!
*/
Function p_CheckAnswer(answer)
If answer <> correct
If score >= 5 Then score = score - 5
PlaySample(4)
Else
score = score + 5
PlaySample(3)
EndIf
DisplayBrush(2, 0, 627)
; update status text
TextOut(#CENTER, 237, "Questions: " .. qc .. " - Score: " .. score)
; ask 20 questions!
If qc < 20
p_NextQuestion(answer)
Else
p_GameOver()
EndIf
EndFunction
/*
** this function is called after 10 questions were asked
*/
Function p_GameOver()
gameon = False
DisplayBGPicPart(1, 0, 96, 627, 154)
For Local k = 2 To 5 Do DisableButton(k)
Wait(100)
TextOut(#CENTER, 102, "Du hast " .. score .. " Prozentpunkte erreicht!")
SetMargins(6, 315)
Locate(0, 128)
If score >= 100
Print("Einhundert Prozent richtig....Ich bin sprachlos, herzlichen Glückwunsch")
PlaySample(1)
ElseIf score >= 95
Print("Wow, fast alles richtig....sehr gut")
PlaySample(1)
ElseIf score >= 80
Print("Das ist wirklich gut")
PlaySample(1)
ElseIf score >= 65
Print("Nett...aber da geht noch was")
PlaySample(1)
ElseIf score >= 50
Print("Ausbaufähig, das geht noch deutlich besser")
PlaySample(1)
ElseIf score >= 25
Print("Also ehrlich gesagt, ein wenig lernen")
PlaySample(2)
Else
Print("Oh weh, das heißt noch üben,üben,üben oder besser raten")
PlaySample(2)
EndIf
TextOut(#CENTER, 237, "Drücke den linken Maus-Knopf")
WaitLeftMouse
; restart!
p_MainMenu()
EnableButton(1)
EndFunction
/*
** the event func will be entered when a button is pressed
*/
Function p_EventFunc(msg)
; are we in game mode or not?
If gameon = False
If msg.action = "OnMouseUp" And msg.id = 1 Then p_StartGame()
Else
Switch msg.action
Case "OnMouseOut":
Box(msg.x, msg.y, msg.width, msg.height, #BLACK)
Case "OnMouseOver":
Box(msg.x, msg.y, msg.width, msg.height, #RED)
Case "OnMouseUp":
p_CheckAnswer(msg.id - 1)
EndSwitch
EndIf
EndFunction
qloc = { {0, 1, 2, 3}, {1, 0, 2, 3}, {1, 2, 0, 3}, {3, 1, 2, 0} }
questions$ = {}
ques = {}
text$= {"",
"Willkommen zum Silviahemmet-Quiz V 0.1 Alpha",
"(c) 2015 Arnim Wolff",
"Kontaktadresse:",
"Malteser Krankenhaus St.Franziskus c/o Arnim Wolff",
"Station Silvia",
"Waldstraße 17",
"24939 Flensburg",
"0461/816-2340",
"Press LMB für Beginn - ESC für Ende",
"",
"Sende mir eine Postkarte wenn es Dir gefällt",
"oder neue Fragen einfallen oder",
"wen Du mir ein Geschenk machen willst",
"",
""}
OpenFile(1,"Questions.txt")
; load all questions into our array
While Not Eof(1)
questions$[q] = ReadLine(1)
q = q + 1
Wend
q = q - 1
CloseFile(1)
evtfunc = {OnMouseUp = p_EventFunc, OnMouseOver = p_EventFunc, OnMouseOut = p_EventFunc}
; show main menu
p_MainMenu()
; make buttons
MakeButton(1, #SIMPLEBUTTON, 0, 0, 320, 260, evtfunc)
MakeButton(2, #SIMPLEBUTTON, 6, 123, 627, 17, evtfunc)
MakeButton(3, #SIMPLEBUTTON, 6, 151, 627, 18, evtfunc)
MakeButton(4, #SIMPLEBUTTON, 6, 179, 627, 17, evtfunc)
MakeButton(5, #SIMPLEBUTTON, 6, 206, 627, 18, evtfunc)
; disable gaming buttons
For k = 2 To 5 Do DisableButton(k)
EscapeQuit(True)
; main loop!
Repeat
WaitEvent
Many thanks for your help