--------------  card 48---------
On opencard 48
  put 48 into presentcard
  put 0 into init48
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

put 1 into gd


putInt 0 into fld timeclock
put 0 into tc

put 0.5 into hspeed
putFloat1 hspeed into fld horse_speed

put 7 into mcounter
putInt mcounter into fld runminutes

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


On minutesup
put mcounter + 1 into  mcounter
if mcounter > 15 then
    put 1 into mcounter
end if
putInt mcounter into fld runminutes

end minutesup



On SpeedUp
put hspeed + 0.1 into hspeed
if hspeed > 0.9 then
 put 0.1 into hspeed
end if
putFloat1 hspeed into fld horse_speed

End SpeedUp


on randomSpeedTime
put random(15 ) into xxx15
put random(9) into xxx9

repeat xxx15 times
minutesup
end repeat

repeat xxx9 times
SpeedUp
end repeat

End randomSpeedTime



on randomSpeedTime2
put random(7 ) into xxx15
put random(9) into xxx9

repeat xxx15 times
minutesup
end repeat

repeat xxx9 times
SpeedUp
end repeat

End randomSpeedTime2








On q_clock48
hide btn "Make horse run !"

put 0  into clock48
Setclock48
 if game_on is  1 and init48 = 0 then
play horse
--   put 3 into ntx
--   naratoranimex
 put 1 into init48
  end if

randomSpeedTime


put  hspeed * mcounter into distancerun
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
putString  "" into fld answer



put 0 into quiz_quit
 
  QuizDlg8 "The horse will run  _____Km ", distancerun
 
      repeat while quiz_quit = 0
         wait 30 ticks
      end repeat
if math_answer is not -1 then

put math_answer2 into guessnumber
putFloat1 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
show btn "Make horse run !"
hide fld youranswer
hide fld answer
hide fld minutes
unlock screen

End q_clock48
---------------------------



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

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

On FunUp48
	repeat while mouse() is down
		put clock48 + 1 into clock48
		if clock48 >= 720 then
			put clock48 - 720 into clock48
		end if
		SetClock48
		wait 10 ticks
	end repeat
end FunUp48

On FunDown48
	repeat while mouse() is down
		put clock48 - 1 into clock48
		if clock48 < 0 then
			put clock48 + 720 into clock48
		end if
		SetClock48
		wait 10 ticks
	end repeat
end FunDown48

On JikanUp48
	repeat while mouse() is down
		put clock48 + 60 into clock48
		if clock48 >= 720 then
			put clock48 - 720 into clock48
		end if
		SetClock48
		wait 10 ticks
	end repeat
end JikanUp48

On JikanDown48
	repeat while mouse() is down
		put clock48 - 60 into clock48
		if clock48 < 0 then
			put clock48 + 720 into clock48
		end if
		SetClock48
		wait 10 ticks
	end repeat
end JikanDown48





On  MoveHorseClock
set loc of btn horse1 to XoriginalP, YoriginalP
put 10/hspeed into xxxx
put 450/(xxxx * 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 mcounter

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

SetClock48
putInt  tc into fld Timeclock
if game_on is not 1 then
wait 1 ticks
if mouseclick() then
 exit repeat
end if
end if


end repeat


End horserun




On Trystart
play click_c
lock screen
hide btn "Make horse run !"
show fld clickstop
unlock screen
put 0 into p_distance
PutFloat1 p_distance into fld present_distance
MoveHorseClock
lock screen
show btn "Make horse run !"
hide fld clickstop
unlock screen
end Trystart



-------------- end card 48 ---------
