I am making a simple math game and it tells you if you are right or wrong.
The problem is it says i'm wrong every time unless I type in the same number every time until it finally says right.
I think it has something to do with the Rnd(0,9) code because I put instead of Rnd, just 5, and when I typed in 10 it said I was right.
Here's the code:
Graphics 800,600
planetmath=LoadImage("planetmath.bmp")
beep=LoadSound("beep.wav")
beeplow=LoadSound("beeplow.wav")
SetBuffer BackBuffer()
font=LoadFont("Impact",72,True,False)
SetFont font
While Not KeyHit(1)
SeedRnd MilliSecs()
number1=Rnd(0,9)
number2=Rnd(0,9)
DrawImage planetmath,0,0
Color 0,0,0
Text 430,320,number1
Text 493,325,"+"
Text 557,320,number2
Text 609,325,"="
Color 0,255,0
If number1+number2=guess Then
Text 600,410,"Right"
PlaySound beep
Else
Color 255,0,0
Text 600,410,"Wrong"
PlaySound beeplow
EndIf
Locate 660,320
guess=Input("")
Flip
Cls
Wend
-thanks
The problem is it says i'm wrong every time unless I type in the same number every time until it finally says right.
I think it has something to do with the Rnd(0,9) code because I put instead of Rnd, just 5, and when I typed in 10 it said I was right.
Here's the code:
Graphics 800,600
planetmath=LoadImage("planetmath.bmp")
beep=LoadSound("beep.wav")
beeplow=LoadSound("beeplow.wav")
SetBuffer BackBuffer()
font=LoadFont("Impact",72,True,False)
SetFont font
While Not KeyHit(1)
SeedRnd MilliSecs()
number1=Rnd(0,9)
number2=Rnd(0,9)
DrawImage planetmath,0,0
Color 0,0,0
Text 430,320,number1
Text 493,325,"+"
Text 557,320,number2
Text 609,325,"="
Color 0,255,0
If number1+number2=guess Then
Text 600,410,"Right"
PlaySound beep
Else
Color 255,0,0
Text 600,410,"Wrong"
PlaySound beeplow
EndIf
Locate 660,320
guess=Input("")
Flip
Cls
Wend
-thanks