--------------  card 46---------
On opencard 46
  put 46 into presentcard
  put 0 into init46
put 0  into clock46
if game_on is not 1 then
play yo_idon2
 
   put 2 into ntx
   naratoranimex
wait 30 ticks
play bokuwo
 
   put 3 into ntx
   naratoranimex
end if

putInt 1 into fld goal_distance
putInt 1 into fld goal_distance2
put 1 into gd


putInt 0 into fld timeclock
put 0 into tc

put 999 into dice
put 1 into ticklength
put LocH of btn horse1 into XoriginalP
put LocV of btn horse1 into YoriginalP
put random(30) into xxxxx
put random(3) into xxx
repeat xxxxx times
goalup
end repeat

repeat xxx times
speedup
end repeat
put gd / hspeed into takeminutes
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
putString  "" into fld answer

end opencard


On goalup
put gd + 1 into gd
if gd > 11 then
    put 1 into gd
end if
putInt gd into fld goal_distance
putInt gd into fld goal_distance2

end goalup

On goaldown
put gd - 1 into gd
if gd < 0 then
    put 11 into gd
end if
putInt gd into fld goal_distance
putInt gd into fld goal_distance2

end goaldown



On goalup2
put gd + 1 into gd
if gd > 5 then
    put 1 into gd
end if
putInt gd into fld goal_distance
putInt gd into fld goal_distance2

end goalup2





On SpeedUp
if dice = 999 then
put 0.5 into hspeed
put 0 into dice
else
put 0.2 into hspeed
put 999 into dice
end if
putFloat1 hspeed into fld horse_speed

End SpeedUp





On q_clock46
put 0  into clock46
Setclock46
 if game_on is  1 and init46 = 0 then
--play imananji
--   put 3 into ntx
--   naratoranimex
 put 1 into init46
  end if
put random(11) into xxxxx
put random(3) into xxx
repeat xxxxx times
goalup
end repeat

repeat xxx times
speedup
end repeat
put gd / hspeed into takeminutes
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
putString  "" into fld answer



put 0 into quiz_quit
 
  QuizDlg7 "How much time does the horse take to reach the finish line?", takeminutes
 
      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
if math_answer is not -1 then

put math_answer2 into guessnumber
putInt math_answer2 into fld answer
show fld youranswer
show fld answer
show fld minutes

MoveHorseClock

end if






  if math_answer is not 1 then
         if math_answer is  -1 then
          play  uhoh2
          else
              play jawharp
              showwitch_surprised
          end if
       else
           play good
           show_frog_good
      end if
lock screen
hide fld youranswer
hide fld answer
hide fld minutes
unlock screen

End q_clock46
---------------------------

On q_clock46_2
-----------------

putInt 1 into fld goal_distance
putInt 1 into fld goal_distance2
put 1 into gd


putInt 0 into fld timeclock
put 0 into tc

put 999 into dice
put 1 into ticklength
put LocH of btn horse1 into XoriginalP
put LocV of btn horse1 into YoriginalP
put random(30) into xxxxx
put random(3) into xxx
repeat xxxxx times
goalup
end repeat

repeat xxx times
speedup
end repeat
put gd / hspeed into takeminutes
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
putString  "" into fld answer



----------------
put 0  into clock46
Setclock46
 if game_on is  1 and init46 = 0 then
--play imananji
--   put 3 into ntx
--   naratoranimex
 put 1 into init46
  end if
put random(11) into xxxxx
put random(3) into xxx
repeat xxxxx times
goalup
end repeat

repeat xxx times
speedup
end repeat
put gd / hspeed into takeminutes
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
putString  "" into fld answer



put 0 into quiz_quit
 
  QuizDlg7 "How much time does the horse take to reach the finish line?", takeminutes
 
      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
if math_answer is not -1 then

put math_answer2 into guessnumber
putInt math_answer2 into fld answer
show fld youranswer
show fld answer
show fld minutes

MoveHorseClock





end if






  if math_answer is not 1 then
         if math_answer is  -1 then
          play  uhoh2
          else
              play jawharp
              showwitch_surprised
          end if
       else
           play good
           show_frog_good
      end if
lock screen
hide fld youranswer
hide fld answer
hide fld minutes
unlock screen

End q_clock46_2


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

On SetClock46
	put clock46 mod 60 into fun
	set data of btn PinLong to fun * 6
	set data of btn PinShort to clock46 * 0.5
end SetClock46

On FunUp46
	repeat while mouse() is down
		put clock46 + 1 into clock46
		if clock46 >= 720 then
			put clock46 - 720 into clock46
		end if
		SetClock46
		wait 10 ticks
	end repeat
end FunUp46

On FunDown46
	repeat while mouse() is down
		put clock46 - 1 into clock46
		if clock46 < 0 then
			put clock46 + 720 into clock46
		end if
		SetClock46
		wait 10 ticks
	end repeat
end FunDown46

On JikanUp46
	repeat while mouse() is down
		put clock46 + 60 into clock46
		if clock46 >= 720 then
			put clock46 - 720 into clock46
		end if
		SetClock46
		wait 10 ticks
	end repeat
end JikanUp46

On JikanDown46
	repeat while mouse() is down
		put clock46 - 60 into clock46
		if clock46 < 0 then
			put clock46 + 720 into clock46
		end if
		SetClock46
		wait 10 ticks
	end repeat
end JikanDown46





On  MoveHorseClock
set loc of btn horse1 to XoriginalP, YoriginalP

put 450/(takeminutes*8) into unitdot

putInt 0 into fld timeclock
put 0 into tc

horserun
End  MoveHorseClock










On horserun
put 0 into unitcount
play hooves3
wait 30 ticks

repeat while 1=1
if mouseclick() is FALSE then

 exit repeat
end if
end repeat




repeat with i = 1 to guessnumber

put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse2
unlock screen

put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance
 

put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse3
unlock screen

put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance



put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse4
unlock screen


put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance


put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse5
unlock screen



put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance





put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse6
unlock screen

put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance


put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse7
unlock screen


put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance




put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse8
unlock screen

put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance



put unitcount + 1 into unitcount

lock screen
set loc of btn horse1 to XoriginalP - unitcount * unitdot,YoriginalP
set bitmap of btn horse1 to horse1
unlock screen
put hspeed * unitcount/8 into p_distance
PutFloat1 p_distance into fld present_distance




put tc + 1 into tc
put tc into clock46
play click_f
SetClock46
putInt  tc into fld Timeclock
wait 1 ticks
if mouseclick() then
exit repeat
end if

end repeat


End horserun




On Trystart
play click_c
lock screen
hide btn "Make Horse Run!"
show fld clickstop
unlock screen
put gd / hspeed into takeminutes
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
put takeminutes into guessnumber
MoveHorseClock
lock screen
show btn "Make Horse Run!"
hide fld clickstop
unlock screen
end Trystart


-------------- end card 46 ---------
