On OpenCard
If Game_on is not 1 then
    play doriru
    put 3 into ntx
    naratoranimex
   wait 2 seconds
   play bokuwo
    put 5 into ntx
   naratoranimex
end if
-- BUNBO Fill-----
repeat with i = 1 to 16
put random(15) into a_number
put a_number  into Item i of fldarray
putInt Item i of fldarray into fld %i%
----BUNSI Fill------
put random( a_number ) into b_number
put b_number  into Item (i + 20) of fldarray
put i + 20 into i20
putInt Item (i+ 20) of fldarray into fld %i20%


put 0 into Item i of checkarray
end repeat


put 25 into Item 1 of btnarray
put 24 into Item 2 of btnarray
put 15 into Item 3 of btnarray
put 18 into Item 4 of btnarray
put 12 into Item 5 of btnarray
put 26 into Item 6 of btnarray
put 19 into Item 7 of btnarray
put 14 into Item 8 of btnarray
put 16 into Item 9 of btnarray
put 20 into Item 10 of btnarray
put 13 into Item 11 of btnarray
put 23 into Item 12 of btnarray
put 21 into Item 13 of btnarray
put 17 into Item 14 of btnarray
put 22 into Item 15 of btnarray
put 27 into Item 16 of btnarray



put 0 into initialLOc
 Reset34
put 0 into initial32flag
put 0 into gamestart2flag
put 0 into card32Keynumber

End OpenCard







On Reset34

-- BUNBO Fill-----
repeat with i = 1 to 16
put random(15) into a_number
put a_number  into Item i of fldarray
putInt Item i of fldarray into fld %i%
----BUNSI Fill------
put random( a_number ) into b_number
put b_number  into Item (i + 20) of fldarray
put i + 20 into i20
putInt Item (i+ 20) of fldarray into fld %i20%


put 0 into Item i of checkarray
end repeat



put 25 into Item 1 of btnarray
put 24 into Item 2 of btnarray
put 15 into Item 3 of btnarray
put 18 into Item 4 of btnarray
put 12 into Item 5 of btnarray
put 26 into Item 6 of btnarray
put 19 into Item 7 of btnarray
put 14 into Item 8 of btnarray
put 16 into Item 9 of btnarray
put 20 into Item 10 of btnarray
put 13 into Item 11 of btnarray
put 23 into Item 12 of btnarray
put 21 into Item 13 of btnarray
put 17 into Item 14 of btnarray
put 22 into Item 15 of btnarray
put 27 into Item 16 of btnarray




put 41 into Item 1 of picturearray
put 42 into Item 2 of picturearray
put 43 into Item 3 of picturearray
put 44 into Item 4 of picturearray
put 45 into Item 5 of picturearray
put 46 into Item 6 of picturearray
put 47 into Item 7 of picturearray
put 48 into Item 8 of picturearray
put 49 into Item 9 of picturearray
put 50 into Item 10 of picturearray
put 51 into Item 11 of picturearray
put 52 into Item 12 of picturearray
put 53 into Item 13 of picturearray
put 54 into Item 14 of picturearray
put 55 into Item 15 of picturearray
put 56 into Item 16 of picturearray






lock screen
repeat with Original = 1 to 16
put Item Original of btnarray into oo
put Item Original of picturearray into ooo
show btn %oo%
set bitmap of btn %oo% to hidebtn 
hide btn %ooo%
hide fld %Original%
put original + 20 into original20
hide fld %Original20%

end repeat

unlock screen

repeat 32 times
put random(16) into r16_1
put random(16) into r16_2
put Item r16_1 of picturearray into switchpictureno
put Item r16_2 of picturearray into Item r16_1 of picturearray
put switchpictureno into Item r16_2 of picturearray 
end repeat

put 0 into gameflag   
put 0 into matching  

put 0 into clicknum
End Reset34









On GameStart
put 0 into rightanswer
put 0 into mistake
putInt 0 into fld right_ans
putInt 0 into fld TotalQ
 Reset34
put 1 into gameflag   
put 0 into clicknum
putInt clicknum into fld clickednum
if initial32flag is not 999 then
  quizmessage
  put 999 into initial32flag
end if
End GameStart















------------------------Animation

On AroSaulsMOve
play dinasaur
repeat 2 times
set bitmap of btn arosaul1 to arosaul2
wait 2 ticks
set bitmap of btn arosaul1 to arosaul3
wait 2 ticks
set bitmap of btn arosaul1 to arosaul2
wait 2 ticks
set bitmap of btn arosaul1 to arosaul1
wait 2 ticks
end repeat
End AroSaulsMOve


----------

On OltMove
play vulture
repeat with i = 1 to 20
if i MOD 2 = 0 then
  set bitmap of btn Olt_an1 to Olt_an2
else
   set bitmap of btn Olt_an1 to Olt_an1
end if
set loc of btn olt_an1 to 700- (i-1) * 40, 320
end repeat
End OltMove

---------------------------------



On picturecompare
if matching = 0 then
put Item n of btnarray into originalloc
put Item n of picturearray into picture1 
lock screen
set loc of btn %picture1% to LocH of btn %originalloc%,LocV of btn %originalloc%
show btn %picture1%
unlock screen
put matching + 1 into matching
put n into  initialloc
put originalloc into Ooriginalloc
put picture1 into Opicture1
else
    if initialloc = n then
      play cough
    else
      put Item n of btnarray into originalloc
      put Item n of picturearray into picture1 
      lock screen
      set loc of btn %picture1% to LocH of btn %originalloc%,LocV of btn %originalloc%
      show btn  %picture1%
      unlock screen
      wait 10 ticks
      put matching + 1 into matching
      if matching = 2 then
          CheckMatchOK
          if result = -1  then
           play expng
           lock screen
           hide btn %Opicture1% 
           hide btn %picture1% 
           unlock screen
           put 0 into matching
          else
           play expok
           hide btn %Ooriginalloc%
           hide btn %originalloc%
           hide btn %Opicture1%
           hide btn %picture1%
           CallQuestion
           put 0 into matching
           put 0 into initialloc
          end if
       end if
     end if
end if
end picturecompare



On CheckMatchOK


if (Opicture1 = 41) and (picture1 = 42) or ( Opicture1 = 42) and (picture1 = 41) then
  put 0 into result
  exit CheckMatchOK
end if




if Opicture1= 43 and picture1 = 44 or Opicture1= 44 and picture1= 43 then
  put 0 into result
  exit CheckMatchOK
end if









if Opicture1= 45 and picture1 = 46 or Opicture1= 46 and picture1= 45 then
  put 0 into result
  exit CheckMatchOK
end if

if Opicture1= 47 and picture1 = 48 or Opicture1= 48 and picture1= 47 then
  put 0 into result
  exit CheckMatchOK
end if

if Opicture1= 49 and picture1 = 50 or Opicture1= 50 and picture1= 49 then
  put 0 into result
  exit CheckMatchOK
end if

if Opicture1= 51 and picture1 = 52 or Opicture1= 52 and picture1= 51 then
  put 0 into result
  exit CheckMatchOK
end if

if Opicture1= 53 and picture1 = 54 or Opicture1= 54 and picture1= 53 then
  put 0 into result
  exit CheckMatchOK
end if

if Opicture1= 55 and picture1 = 56 or Opicture1= 56 and picture1= 55 then
  put 0 into result
  exit CheckMatchOK
end if
  put -1  into result

End CheckMatchOK










on CheckNumber1
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 1 into n
picturecompare
end if
end  CheckNumber1


on CheckNumber2
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 2 into n
picturecompare
end if
end  CheckNumber2


on CheckNumber3
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 3 into n
picturecompare
end if
end  CheckNumber3


on CheckNumber4
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 4 into n
picturecompare
end if
end  CheckNumber4


on CheckNumber5
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 5 into n
picturecompare
end if
end  CheckNumber5


on CheckNumber6
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 6 into n
picturecompare
end if
end  CheckNumber6


on CheckNumber7
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 7 into n
picturecompare
end if
end  CheckNumber7


on CheckNumber8
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 8 into n
picturecompare
end if
end  CheckNumber8


on CheckNumber9
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 9 into n
picturecompare
end if
end  CheckNumber9


on CheckNumber10
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 10 into n
picturecompare
end if
end  CheckNumber10


on CheckNumber11
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 11 into n
picturecompare
end if
end  CheckNumber11


on CheckNumber12
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 12 into n
picturecompare
end if
end  CheckNumber12


on CheckNumber13
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 13 into n
picturecompare
end if
end  CheckNumber13


on CheckNumber14
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 14 into n
picturecompare
end if
end  CheckNumber14


on CheckNumber15
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 15 into n
picturecompare
end if
end  CheckNumber15


on CheckNumber16
if Gameflag = 1 then
put clicknum + 1 into clicknum
putInt clicknum into fld clickednum
put 16 into n
picturecompare
end if
end  CheckNumber16

-----------------------
On CallQuestion

      put initialloc into jjj
       Lock screen
       put Item jjj of btnarray into bbb
        hide btn %bbb%
          putInt Item jjj of fldarray into fld %jjj%
          put jjj + 20 into jjj20
          putInt Item jjj20 of fldarray into fld %jjj20%


       show fld %jjj%
       show fld %jjj20%
        set loc of btn hidebtn1 to LocH of btn %bbb%, LocV of btn %bbb%
       show btn hidebtn1
       unlock screen









-------------------
        put n into kkk
         
     Lock screen
       put Item kkk of btnarray into ccc
        hide btn %ccc%

      put Item jjj of fldarray into Item kkk of fldarray
       putInt Item kkk of fldarray into fld %kkk%
      put random(Item kkk of fldarray) into kkknumber
     
      put kkk + 20 into kkk20
       put kkknumber into Item kkk20 of fldarray
       putInt Item kkk20 of fldarray into fld %kkk20%

        show fld %kkk%
        show fld %kkk20%
        set loc of btn hidebtn2 to LocH of btn %ccc%, LocV of btn %ccc%
       show btn hidebtn2
      unlock screen


if random(2) = 1 then
     put (Item JJJ20 of fldarray) + (Item kkk20 of fldarray) into number1



     put (Item JJJ of fldarray) into number2
     
     QuizDlg10 "The sum of two fractions is ___", number2,number1
     
 

else

     put (Item JJJ of fldarray)  into number2

  if (Item JJJ20 of fldarray) >= (Item kkk20 of fldarray) then
        put (Item JJJ20 of fldarray) - (Item kkk20 of fldarray) into number1

     QuizDlg10 "The difference between two fractions is ___", number2,number1
    else
          put  (Item kkk20 of fldarray)-(Item JJJ20 of fldarray)  into number1
      
     QuizDlg10 "The difference between two fractions is ___", number2,number1
    end if



end if



       if gamestartflag = 999 then
           put card32Keynumber + 1 into card32Keynumber
       end if

      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
      put 0 into quiz_quit

  if math_answer is not 1 then
       if math_answer is  -1 then
          play  uhoh2
        lock screen
        show btn %ccc%
        hide fld %kkk%
        hide fld %kkk20%
        show btn %bbb%
        hide fld %jjj%
        hide fld %jjj20%
       hide btn hidebtn1
       hide btn hidebtn2
        unlock screen
        reset34
        else
              play jawharp
          showwitch_surprised
            put mistake + 1 into mistake
            putInt rightanswer + mistake into fld TotalQ
      end if
       if gamestartflag = 999 then
            enable menu Index
            put 0 into gamestartflag
            exit CallQuestion
       end if

        lock screen
        show btn %ccc%
        hide fld %kkk%
        hide fld %kkk20%
        show btn %bbb%
        hide fld %jjj%
        hide fld %jjj20%
       hide btn hidebtn1
       hide btn hidebtn2
        unlock screen
   else
           play good
           show_frog_good
          put rightanswer + 1 into rightanswer
          putInt rightanswer + mistake into fld TotalQ
          putInt rightanswer into fld right_ans
       if gamestartflag = 999 and  card32Keynumber=2 then
        enable menu Index
           put 0 into gamestartflag

        exit callquestion
       end if

     put 1 into Item jjj of checkarray
     put 1 into Item kkk of checkarray
    lock screen
     hide btn hidebtn1
     hide btn hidebtn2
     hide fld %jjj%
     hide fld %kkk%
     hide fld %jjj20%
     hide fld %kkk20%
     unlock screen
     put 0 into allcheckedng
     repeat with lmn = 1 to 16
     if item lmn of checkarray is not 1 then
         put 1 into allcheckedng
     end if  
    end repeat
     if allcheckedng = 0  then
         oltmove     
         arosaulsmove
      play toomuch
      wait 2 seconds
      reset34

 
      end if
 end if



     
    
 
End CallQuestion



On quizmessage
show btn t_writer
message2 141, 28, 9, "This is the picture matching quiz! If you select the matching pictures, a question will be asked. Good Luck!"
hide btn t_writer

End quizmessage


On kumoMove
play gullbee
put random(5) into n

repeat with i = 1 to n
 set bitmap of btn  Kumo to Kumo2
wait 1 ticks
 set bitmap of btn  Kumo to Kumo
wait 1 ticks

end repeat

End kumoMove




On GameStart2
put 0 into card32Keynumber



hide btn sansumap
hide btn "Go Penguin's Sharing"
disable menu index
put 0 into rightanswer
put 0 into mistake
putInt 0 into fld right_ans
putInt 0 into fld TotalQ
 Reset34
put 1 into gameflag   
put 0 into clicknum
putInt clicknum into fld clickednum
  quizmessage
put 999 into gamestart2flag
repeat while  gamestart2flag=999
wait 1 ticks
if mouseclick() then
 click at CLICKH(), CLICKV()
end if
end repeat
End GameStart2

