--------------  card 47---------
On opencard 47
  put 47 into presentcard
  put 0 into init47
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
  randomset

 put LocH of btn horse into OXoriginalP
 put LocV of btn horse into OYoriginalP

end if




putInt 0 into fld timeclock
put 0 into tc

put 1 into ticklength
put LocH of btn horse1 into XoriginalP
put LocV of btn horse1 into YoriginalP
end opencard



On goalup
put gd + 0.4 into gd
if gd > 11 then
    put 0.4 into gd
end if
putFLOAT1 gd into fld goal_distance
putFloat1 gd into fld goal_distance2

end goalup



On SpeedUp
if dice = 999 then
put 0.4 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 randomset
putString  "" into fld answer
put 0 into gd
put random(11) into r1
repeat r1 times
goalup
end repeat
put random(5) into r1
repeat r1 times
speedup
end repeat

end randomset




On q_clock47


putInt 0 into fld timeclock
put 0 into tc
putString  "" into fld answer

put 0  into clock47
Setclock47
 if game_on is  1 and init47 = 0 then
play horse
 put 1 into init47
  end if

 put 0 into quiz_quit

 
randomset



put 0 into p_distance
PutFloat1 p_distance into fld present_distance

put gd / hspeed into takeminutes


put 0 into quiz_quit

 
  QuizDlg7 "How many minutes for the horse 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


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

End q_clock47
---------------------------



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

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

On FunUp47
	repeat while mouse() is down
		put clock47 + 1 into clock47
		if clock47 >= 720 then
			put clock47 - 720 into clock47
		end if
		SetClock47
		wait 10 ticks
	end repeat
end FunUp47

On FunDown47
	repeat while mouse() is down
		put clock47 - 1 into clock47
		if clock47 < 0 then
			put clock47 + 720 into clock47
		end if
		SetClock47
		wait 10 ticks
	end repeat
end FunDown47

On JikanUp47
	repeat while mouse() is down
		put clock47 + 60 into clock47
		if clock47 >= 720 then
			put clock47 - 720 into clock47
		end if
		SetClock47
		wait 10 ticks
	end repeat
end JikanUp47

On JikanDown47
	repeat while mouse() is down
		put clock47 - 60 into clock47
		if clock47 < 0 then
			put clock47 + 720 into clock47
		end if
		SetClock47
		wait 10 ticks
	end repeat
end JikanDown47





On  MoveHorseClock
set loc of btn horse1 to XoriginalP, YoriginalP
put gd/hspeed into takeminutes

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
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 clock47
play click_f

SetClock47
putInt  tc into fld Timeclock

end repeat


End horserun




On Trystart

putInt 0 into fld timeclock
put 0 into tc

put 1 into ticklength
set loc of btn horse to  OXoriginalP, OYoriginalP
 




putString  "" into fld answer

put 0  into clock47
Setclock47
 
 

put 0 into p_distance
PutFloat1 p_distance into fld present_distance




put Int (gd / hspeed + 0.5 ) into guessnumber



MoveHorseClock






end Trystart



-------------- end card 47 ---------
