Author Topic: Times Table Test  (Read 1349 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Times Table Test
« on: October 27, 2021 »
12 x table.

L/R D-Pad to choose.

Control to enter.

End to reset.

Code: [Select]
first_number=int(ran(12))+1
second_number=int(ran(12))+1
position_right_answer=int(ran(4))+1
choice=1
go1=81
go2=1
go3=9
t=0
dim false_answer(4)

for a=1 to 4
false_answer(a)=int(ran(144))+1
next a

open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,0,250,0
fill rectangle 0,0 to 640,512
setrgb 1,0,0,0

for a=1 to 5
rectangle a,a to (5-a)+635,(5-a)+507
next a

setrgb 1,256,256,0
fill rectangle 150,150 to 490,300
setrgb 1,0,0,0

for a=1 to 5
rectangle a+145,a+145 to (5-a)+490,(5-a)+300
next a

c=peek("port1")
go=go+1
if go>10 go=10

if and(c,128)>0 and go=10 then
choice=choice-1
go=1
endif

if and(c,32)>0 and go=10 then
choice=choice+1
go=1
endif

if choice<1 choice=1
if choice>4 choice=4
setrgb 1,0,0,0

for a=1 to 4
text a*40+250,200,str$(false_answer(a))
next a

text 200,200,str$(first_number)+" x "+str$(second_number)+" ="

clear fill rectangle position_right_answer*40+250,185 to position_right_answer*40+281,205

setrgb 1,256,256,0
fill rectangle position_right_answer*40+250,185 to position_right_answer*40+281,205

setrgb 1,0,0,0
text position_right_answer*40+250,200,str$(first_number*second_number)
rectangle choice*40+250,182 to choice*40+280,209

go1=go1+1
if go1>81 go1=81
go2=go2+1
if go2>541+t go2=541+t

if choice=position_right_answer and and(c,1024)>0 then
go1=1
go2=1
endif

if choice=position_right_answer and go1<40 then
clear fill rectangle 290,175 to 370,210
setrgb 1,250,150,0
fill rectangle 290,175 to 370,210
setrgb 1,0,0,0
rectangle 290,175 to 370,210
text 300,200,"RIGHT!"
endif

if choice=position_right_answer and go1=39 right=right+1

if choice<>position_right_answer and and(c,1024)>0 then
go1=1
go2=1
endif

if choice<>position_right_answer and go1<40 then
clear fill rectangle 290,175 to 370,210
setrgb 1,250,150,0
fill rectangle 290,175 to 370,210
setrgb 1,0,0,0
rectangle 290,175 to 370,210
text 300,200,"WRONG!"
endif

if choice<>position_right_answer and go1=39 wrong=wrong+1

text 200,240,"right answers-"+str$(right)
text 200,260,"wrong answers-"+str$(wrong)

if and(c,8192)>0 then
right=0
wrong=0
endif

if go2>260+t and go2<299+t then
gosub timer_box
text 300,200,"HURRY UP!"
endif

if go2>360+t and go2<399+t then
gosub timer_box
text 300,200,"COME ON!"
endif

if go2>460+t and go2<499+t then
gosub timer_box
text 300,200,"TOO LONG!"
endif

if go2>539+t wrong=wrong+1

if go1>40 and go1<80 or go2>499+t and go2<540+t then
setrgb 1,256,0,0
fill triangle position_right_answer*40+265,180 to position_right_answer*40+260,165 to position_right_answer*40+270,165
setrgb 1,0,0,0
triangle position_right_answer*40+265,180 to position_right_answer*40+260,165 to position_right_answer*40+270,165
endif

go3=go3+1
if go3>10 go3=10
if go1=80 or go2=540+t go3=1

if go3<9 then
clear fill rectangle 152,150 to 490,210
setrgb 1,256,256,0
fill rectangle 152,150 to 490,210
endif

if go3=9 then
go2=1
first_number=int(ran(12))+1
second_number=int(ran(12))+1
position_right_answer=int(ran(4))+1
choice=1

for a=1 to 4
false_answer(a)=int(ran(144))+1
next a

endif

until (1=0)

label timer_box
clear fill rectangle 290,175 to 400,210
setrgb 1,250,150,0
fill rectangle 290,175 to 400,210
setrgb 1,0,0,0
rectangle 290,175 to 400,210
return
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.