## Sunday, November 24, 2013

### Matching Cards

# Another game for the interactive whiteboard

Dim a\$(4,3)
Dim value(4,3)
Dim pair(2)
Dim pair\$(2)
font "arial",40,40
Graphsize 750,450
time = second+minute*60+hour*3600
QA = 0
do
n1=int(rand*9+1)
n2=int(rand*9+1)
question\$=n1+"x"+n2
#################################
repetition = false
#checking for repetitions
for n=0 to 2
for m=0 to 3
if a\$[m,n]=answer\$ then repetition = true
next m
next n

if repetition = false then
#selecting 1 card for question
Q =0
do
v=int(rand*3)
h=int(rand*4)

if a\$[h,v]="" then
a\$[h,v]= question\$
Q = 1
end if
until Q =1
A =0
do
v=int(rand*3)
h=int(rand*4)
if a\$[h,v]="" then
A = 1
end if
until A =1
QA =QA +2
end if
until QA = 12

# Clicking the cards
cards=12
do
gosub drawcards
p=0
do
clickclear
t=0
do
if second+minute*60+hour*3600>t then
color white
rect 600,0,450,150
color black
text 600,40,second+minute*60+hour*3600 - time+" sec"
t=second+minute*60+hour*3600
end if
until clicky>0
x=int(clickx/150)
y=int(clicky/150)
pair[p]=value[x,y]
pair\$[p]=a\$[x,y]
p=p+1
color red
circle 150*x+20,150*y+20,10
until p=2
pause .5

if pair[0]=pair[1]and pair\$[0]<>pair\$[1] then
for n=0 to 3
for m=0 to 2
if value[n,m]=pair[1]then a\$[n,m]="Yes"
next m
next n
cards=cards-2
end if
until cards=0

drawcards:
for n=0 to 3
for m=0 to 2
color black
if a\$[n,m]="Yes" then color green
Rect 150*n,150*m,140,140
color white
text 150*n+20,150*m+40,a\$[n,m]
next m
next n
return

end