-- director calls tidle automatically all the time -- moleflag is variable that gets set when the event starts -- the mole doesn't move if moleflag is not 1 -- the random(8) makes the move move slower -- eventflag is variable that makes the whole event go -- both moleflag and eventflag are set by the start button -- when the even ends through success or failure they get set to 0 -- keeptrack, moveball,checkballtouch, and mole are all subroutines that get called on idle global moleflag, eventflag if eventflag = 1 then keeptrack moveball checkballtouch if moleflag = 1 then if random (20) = 1 then mole end if end if end if end -- startmovie gets called when movie starts -- it sets moleflag and eventflag = 0 -- so nothing happens till start button is pushed on startmovie global moleflag, eventflag moleflag = 0 eventflag = 0 end -- sets flags to start event -- sets starttick = to current ticks -- sets targettick = 60 seconds later -- 60 x 60 ticks -- could be adjusted to any target length -- setup is routine called by start button on setup global el, starttick, targettick global moleflag,eventflag eventflag = 1 moleflag = 1 starttick = the ticks targettick = starttick + (60*60) end -- does the real time keeping -- curtick = current time when it is called -- el is elapsed time = subtract startime from current time -- cdown is countdown = subtract current time from target time -- divide by 60.0 to get seconds -- then it puts the various times into fields to display them -- that part could be dropped if you didn't want to display them -- checks if elapsed time is greater than (>) 60 -- and then goes and does something ( in this case runs the failure routine) -- could be any event you want to indicated that they didn't succeed -- you could check for any elapsed time that you wanted - eg 30 seconds on keeptrack global el, starttick, targettick,cdown curtick = the ticks el = (curtick-starttick)/60.0 cdown = (targettick-curtick)/60.0 put el into member "el" put cdown into member "cd" if el > 60 then fail end if end -- routine if person gets the mole -- it is called by on mouseUp on the mole sprite -- this example takes them to section with marker called success -- resets the flags on succeed global eventflag, moleflag voicespeak("success") go frame "suc" eventflag = 0 moleflag = 0 end -- assumes there is a section with marker called "endotheworld" -- resets the flags on fail global eventflag, moleflag voicespeak("fail") go frame "endofworld" eventflag = 0 moleflag = 0 end -- optional - shows how moving ball position can be linked to elapsed time -- called by idle on moveball global el sprite(4).locV= el*8 end -- optional - moves the mole sprite to random positions -- called by idle on mole x = random(640) y = random (480) sprite(5).loc = point(x,y) end -- optional - shows how to check if someone has moved one -- sprite into another -- if the 2 sprites touch each other , intersect gives the rectangle of their touch -- if there is no intersection then the answer is rect(0,0,0,0) on checkballtouch a = sprite(7).rect b = sprite (8).rect put intersect(a,b) if intersect(a, b) <> rect(0,0,0,0) then succeed end if end