Posted: 14th Jan 2014 19:09
Hey guys, im trying to make a school quiz game with a timer. The timer works in some ways but it can go to the negatives and the second digit of the timer whites out because the numbers don't disappear. Heres a code snippit:
REM PROJECT
REM SCIENCE PROJECT
autocam off
title:
cls
ink rgb (255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,60, "Welcome Science Mania!"
set text size 15
center text 320,160, "Press X if you don't want to read the instructions"
center text 320,180, "Press H if you want to read the instructions"
do
if inkey$()="x" then gosub ModeSelect
if inkey$()="h" then gosub instructions
loop
Instructions:
cls
ink rgb (255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,60, "Instructions"
set text size 15
Center text 320,160, "Welcome to the Science Mania Test Prep! In this Game"
center text 320,180, "you have to answer as many problems as you can"
ink rgb (0,255,0),0
center text 320,400, "Press B to go back."
do
if inkey$()="b" then gosub title
loop
ModeSelect:
cls
ink rgb (255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,200,"Which subject do you want to select?"
set text size 15
text 240,280,"1.)Math"
text 240,300,"2.)English"
text 240,320,"3.)Science"
center text 320,380, "Press B to go back"
do
if inkey$()="1"
do
if inkey$() <> "1" then exit
loop
gosub GetReady1
endif
GetReady1:
cls
ink rgb(255,255,255),0 : set text font "arial": set text size 30 : set text to normal
center text 320,200, "Get Ready!"
set text size 15
center text 320,260, "Press the space bar to go start"
center text 320,280, "Press B to go back"
do
if inkey$()="b" then gosub title
if Spacekey()=1 then gosub Level1
loop
Level1:
cls
ProblemCorrect = 0
AnswersCorrect = 0
Seconds = 15
T=Timer()
rem put bitmap here later
ink rgb(255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,200,"What is 2+2?"
set text size 15
text 240,280, "A.)2"
text 240,300, "B.)1"
text 240,320, "C.)3"
text 240,340, "D.)4"
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 20,20,"Seconds Left: "+Str$(TimeLeft)
if inkey$()="b"
do
if inkey$() <> "b" then exit
loop
ProblemCorrect = 2
AnswersCorrect = AnswersCorrect + 1
Seconds = Seconds - 5
gosub Level2
endif
if inkey$()="a"
do
if inkey$() <> "a" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level2
endif
if inkey$()="c"
do
if inkey$() <> "c" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level2
endif
if inkey$()="d"
do
if inkey$() <> "d" then exit
loop
ProblemCorrect = 1
Seconds = Seconds + 5
gosub Level2
endif
if TimeLeft <= 9 then Text 105,20," "
if TimeLeft <= 99 then Text 111,20," "
until TimeLeft = 0
end
Level2:
cls
rem load bitmap here
ink rgb(255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,200, "What is 99+1?"
set text size 15
if ProblemCorrect = 1 then ink rgb(0,255,0),0 : center text 320,150, "CORRECT! +5 SECONDS"
if ProblemCorrect = 2 then ink rgb(255,0,0),0 : center text 320,150, " WRONG! -5 SECONDS"
ink rgb(255,255,255),0
text 240,280,"A.)50"
text 240,300,"B.)60"
text 240,320,"C.)100"
text 240,340,"D.)98"
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 20,20,"Seconds Left: "+Str$(TimeLeft)
if inkey$()="b"
do
if inkey$() <> "b" then exit
loop
ProblemCorrect = 2
AnswersCorrect = AnswersCorrect + 1
Seconds = Seconds - 5
gosub Level3
endif
if inkey$()="a"
do
if inkey$() <> "a" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level3
endif
if inkey$()="c"
do
if inkey$() <> "c" then exit
loop
ProblemCorrect = 1
Seconds = Seconds + 5
gosub Level3
endif
if inkey$()="d"
do
if inkey$() <> "d" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level3
endif
if TimeLeft <= 9 then Text 105,20," "
if TimeLeft <= 99 then Text 111,20," "
until TimeLeft = 0
Level3:
cls
rem load bitmap here
ink rgb(255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,200, "What is 56.1+82.3?"
set text size 15
if ProblemCorrect = 1 then ink rgb(0,255,0),0 : center text 320,150, "CORRECT! +5 SECONDS"
if ProblemCorrect = 2 then ink rgb(255,0,0),0 : center text 320,150, " WRONG! -5 SECONDS"
ink rgb(255,255,255),0
text 240,280,"A.)133.4"
text 240,300,"B.)125.4"
text 240,320,"C.)116.2"
text 240,340,"D.)118.4"
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 20,20,"Seconds Left: "+Str$(TimeLeft)
if inkey$()="b"
do
if inkey$() <> "b" then exit
loop
ProblemCorrect = 2
AnswersCorrect = AnswersCorrect + 1
Seconds = Seconds + 5
gosub Level3
endif
if inkey$()="a"
do
if inkey$() <> "a" then exit
loop
ProblemCorrect = 1
Seconds = Seconds + 5
gosub Level3
endif
if inkey$()="c"
do
if inkey$() <> "c" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level3
endif
if inkey$()="d"
do
if inkey$() <> "d" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level3
endif
if TimeLeft <= 9 then Text 105,20," "
if TimeLeft <= 99 then Text 111,20," "
until TimeLeft = 0
Level2:
cls
rem load bitmap here
ink rgb(255,255,255),0 : set text font "arial" : set text size 30 : set text to normal
center text 320,200, "What is 216.7 - 117.4?"
set text size 15
if ProblemCorrect = 1 then ink rgb(0,255,0),0 : center text 320,150, "CORRECT! +5 SECONDS"
if ProblemCorrect = 2 then ink rgb(255,0,0),0 : center text 320,150, " WRONG! -5 SECONDS"
ink rgb(255,255,255),0
text 240,280,"A.)117.6"
text 240,300,"B.)104.3"
text 240,320,"C.)99.3"
text 240,340,"D.)89.3"
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 20,20,"Seconds Left: "+Str$(TimeLeft)
if inkey$()="b"
do
if inkey$() <> "b" then exit
loop
ProblemCorrect = 2
AnswersCorrect = AnswersCorrect + 1
Seconds = Seconds - 5
gosub Level2
endif
if inkey$()="a"
do
if inkey$() <> "a" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level2
endif
if inkey$()="c"
do
if inkey$() <> "c" then exit
loop
ProblemCorrect = 1
Seconds = Seconds + 5
gosub Level2
endif
if inkey$()="d"
do
if inkey$() <> "d" then exit
loop
ProblemCorrect = 2
Seconds = Seconds - 5
gosub Level2
endif
if TimeLeft <= 9 then Text 105,20," "
if TimeLeft <= 99 then Text 111,20," "
until TimeLeft = 0
loop
end
Here is the timer implemented in the game:
repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 20,20,"Seconds Left: "+Str$(TimeLeft)