
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
if a_number = 1 then
 put 1 + random(14) into a_number
end if
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
if a_number = b_number then
 put b_number -1 into b_number
end if
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 29 into Item 1 of hotaruarray
put 32 into Item 2 of hotaruarray
put 37 into Item 3 of hotaruarray
put 38 into Item 4 of hotaruarray
put 52 into Item 5 of hotaruarray
put 33 into Item 6 of hotaruarray
put 39 into Item 7 of hotaruarray
put 41 into Item 8 of hotaruarray
put 30 into Item 9 of hotaruarray
put 34 into Item 10 of hotaruarray
put 42 into Item 11 of hotaruarray
put 40 into Item 12 of hotaruarray
put 31 into Item 13 of hotaruarray
put 35 into Item 14 of hotaruarray
put 36 into Item 15 of hotaruarray
put 43 into Item 16 of hotaruarray







End OpenCard







On Reset34

-- BUNBO Fill-----
repeat with i = 1 to 16
put random(15) into a_number
if a_number = 1 then
 put 1 + random(14) into a_number
end if
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
if a_number = b_number then
 put b_number -1 into b_number
end if
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 29 into Item 1 of hotaruarray
put 32 into Item 2 of hotaruarray
put 37 into Item 3 of hotaruarray
put 38 into Item 4 of hotaruarray
put 52 into Item 5 of hotaruarray
put 33 into Item 6 of hotaruarray
put 39 into Item 7 of hotaruarray
put 41 into Item 8 of hotaruarray
put 30 into Item 9 of hotaruarray
put 34 into Item 10 of hotaruarray
put 42 into Item 11 of hotaruarray
put 40 into Item 12 of hotaruarray
put 31 into Item 13 of hotaruarray
put 35 into Item 14 of hotaruarray
put 36 into Item 15 of hotaruarray
put 43 into Item 16 of hotaruarray






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

end repeat

unlock screen




End Reset34















On hotaruleft

beeleft
End hotaruleft


On hotaruright
beeright
End hotaruright



On GetNumber
put random(16) into r1
put 0 into found
repeat with j = r1 to 16
  if Item j of checkarray = 0 then
     put 1 into found
     exit repeat
  end if
end repeat
if found = 1 then
  exit GetNumber
end if

if found = 0 then
repeat with j = 1 to r1-1
  if Item j of checkarray = 0 then
     put 1 into found
     exit repeat
  end if
end repeat
end if 

End GetNumber




On GameStart
put 0 into rightanswer
put 0 into mistake
putInt 0 into fld right_ans
putInt 0 into fld TotalQ
Repeat while 1=1
 GetNumber
 if found is not 0 then
      put 0 into m
      put 0 into l
      put j into jjj
      put Item jjj of Hotaruarray into hh1
            put hh1 into hotaru_btn_no
       play bee

       if hh1 = 37 or hh1 = 41 or hh1 = 33 or hh1 = 52 or hh1 = 30 or hh1=34 then
          HotaruRight
       else
          HotaruLeft
       end if

       put x0 into h1x
       put y0 into h1y
       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









-------------------
     repeat while 1 = 1
       GetNumber
       if j is not jjj then
          exit repeat
       end if
     end repeat
        put j into kkk
         
      put Item kkk of Hotaruarray into hh2
            put hh2 into hotaru_btn_no
       if hh2 = 37 or hh2 = 41 or hh2 = 33 or hh2 = 52 or hh2 = 30 or hh2=34 then
          HotaruRight
       else
          HotaruLeft
       end if
         put x0 into h2x
        put y0 into h2y

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


       putInt Item kkk of fldarray into fld %kkk%
      put kkk + 20 into kkk20
       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 kkk of fldarray)+ (Item kkk20 of fldarray)*(Item JJJ of fldarray) into number1



     put (Item JJJ of fldarray)*  (Item kkk of fldarray) into number2
     
     QuizDlg10 "The sum of the two fractions is __", number2,number1
     
 

else

     put (Item JJJ20 of fldarray) *(Item kkk of fldarray)- (Item kkk20 of fldarray)*(Item JJJ of fldarray) into number1



     put (Item JJJ of fldarray)*  (Item kkk of fldarray) into number2


if number1 >= 0 then

     QuizDlg10 "The difference between the red and green fractions is ?", number2,number1

else
put number1 * (-1) into number1
     QuizDlg10 "The difference between the red and green fractions is ?", number2,number1
end if





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%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
       show btn %hh1%
       show btn %hh2%
       hide btn hidebtn1
       hide btn hidebtn2
        unlock screen
          exit repeat
        else
              play jawharp
          showwitch_surprised
            put mistake + 1 into mistake
            putInt rightanswer + mistake into fld TotalQ
      end if


        lock screen
        show btn %ccc%
        hide fld %kkk%
        hide fld %kkk20%
        show btn %bbb%
        hide fld %jjj%
        hide fld %jjj20%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
       show btn %hh1%
       show btn %hh2%
       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
     put 1 into Item jjj of checkarray
     put 1 into Item kkk of checkarray
    lock screen
     hide btn %hh1%
     hide btn %hh2%
     hide btn hidebtn1
     hide btn hidebtn2
     hide fld %jjj%
     hide fld %kkk%
     hide fld %jjj20%
     hide fld %kkk20%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
     unlock screen

      end if
 else


    repeat  5 times
    set direction of btn 2 to 1
    set direction of btn 2 to 2
    set direction of btn 2 to 3
    set direction of btn 2 to 0
    end repeat
            play AlRight
     
    set bitmap of btn 2 to frog2
     wait 60 ticks
    set bitmap of btn 2 to frog1
  wait 2 seconds
   play toomuch

   play toomuch
       exit repeat
 end if  





End Repeat 

reset34


     
    
 
End GameStart















On GameStart2

put 0 into rightanswer
put 0 into mistake
putInt 0 into fld right_ans
putInt 0 into fld TotalQ
Repeat 2 times
 GetNumber
 if found is not 0 then
      put 0 into m
      put 0 into l
      put j into jjj
      put Item jjj of Hotaruarray into hh1
            put hh1 into hotaru_btn_no
       play bee

       if hh1 = 37 or hh1 = 41 or hh1 = 33 or hh1 = 52 or hh1 = 30 or hh1=34 then
          HotaruRight
       else
          HotaruLeft
       end if

       put x0 into h1x
       put y0 into h1y
       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









-------------------
     repeat while 1 = 1
       GetNumber
       if j is not jjj then
          exit repeat
       end if
     end repeat
        put j into kkk
         
      put Item kkk of Hotaruarray into hh2
            put hh2 into hotaru_btn_no
       if hh2 = 37 or hh2 = 41 or hh2 = 33 or hh2 = 52 or hh2 = 30 or hh2=34 then
          HotaruRight
       else
          HotaruLeft
       end if
         put x0 into h2x
        put y0 into h2y

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


       putInt Item kkk of fldarray into fld %kkk%
      put kkk + 20 into kkk20
       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 kkk of fldarray)+ (Item kkk20 of fldarray)*(Item JJJ of fldarray) into number1



     put (Item JJJ of fldarray)*  (Item kkk of fldarray) into number2
     
     QuizDlg10 "The sum of the two fractions is ?", number2,number1
     
 

else

     put (Item JJJ20 of fldarray) *(Item kkk of fldarray)- (Item kkk20 of fldarray)*(Item JJJ of fldarray) into number1



     put (Item JJJ of fldarray)*  (Item kkk of fldarray) into number2


if number1 >= 0 then

     QuizDlg10 "The difference between the two fractions is ?", number2,number1

else
put number1 * (-1) into number1
     QuizDlg10 "The difference between the two fractions is ?", number2,number1
end if





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%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
       show btn %hh1%
       show btn %hh2%
       hide btn hidebtn1
       hide btn hidebtn2
        unlock screen
        else
              play jawharp
          showwitch_surprised
            put mistake + 1 into mistake
            putInt rightanswer + mistake into fld TotalQ
      end if


        lock screen
        show btn %ccc%
        hide fld %kkk%
        hide fld %kkk20%
        show btn %bbb%
        hide fld %jjj%
        hide fld %jjj20%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
       show btn %hh1%
       show btn %hh2%
       hide btn hidebtn1
       hide btn hidebtn2
        unlock screen
          exit GameStart2

   else
           play good
           show_frog_good
          put rightanswer + 1 into rightanswer
          putInt rightanswer + mistake into fld TotalQ
          putInt rightanswer into fld right_ans
     put 1 into Item jjj of checkarray
     put 1 into Item kkk of checkarray
    lock screen
     hide btn %hh1%
     hide btn %hh2%
     hide btn hidebtn1
     hide btn hidebtn2
     hide fld %jjj%
     hide fld %kkk%
     hide fld %jjj20%
     hide fld %kkk20%
        set loc of btn %hh1% to h1x, h1y
        set loc of btn %hh2% to h2x, h2y
     unlock screen

      end if
 else


    repeat  5 times
    set direction of btn 2 to 1
    set direction of btn 2 to 2
    set direction of btn 2 to 3
    set direction of btn 2 to 0
    end repeat
            play AlRight
     
    set bitmap of btn 2 to frog2
     wait 60 ticks
    set bitmap of btn 2 to frog1
  wait 2 seconds
   play toomuch

   play toomuch
       exit repeat
 end if  





End Repeat 

reset34


End GameStart2












On beeleft
put random(10) into h
put LocH of btn %hotaru_btn_no% into x0
put LocV of btn %hotaru_btn_no% into y0
put y0 - h * 10 into y1
put x0 /20 into n
put h * 10 /n into nn
repeat with i = 1 to n
 set loc of btn  %hotaru_btn_no% to x0 - (i-1) * 20, y0 - nn *(i-1) + h 
end repeat
hide btn  %hotaru_btn_no%
End beeleft


On beeright
put random(10) into h
put LocH of btn %hotaru_btn_no% into x0
put LocV of btn %hotaru_btn_no% into y0
put y0 - h * 10 into y1
put (640-x0) /20 into n
put h * 10 /n into nn
repeat with i = 1 to n
 set loc of btn  %hotaru_btn_no% to x0  + (i-1) * 20, y0 - nn *(i-1) + h 
end repeat
hide btn  %hotaru_btn_no%

End beeright




