home *** CD-ROM | disk | FTP | other *** search
/ Roboty / ROBOTS_CD.iso / CD / pairs.dxr / 00044.ls < prev    next >
Encoding:
Text File  |  2005-05-13  |  774 b   |  45 lines

  1. global clockSprite, currTime, maxTime, clockLength, startV, inc, glevel
  2.  
  3. on clockSetUp spNum
  4.   inc = 0
  5.   currTime = 0
  6.   maxTime = 120.0
  7.   clockSprite = spNum
  8.   startV = sprite(clockSprite).locV
  9.   clockLength = 250
  10.   if glevel > 1 then
  11.     startClock()
  12.   end if
  13. end
  14.  
  15. on startClock
  16.   inc = 1
  17.   timeout("ClockTick").new(1 * 1000, #clockTick)
  18.   sendAllSprites(#ButtonBlend, "restart", 100)
  19. end
  20.  
  21. on clockTick
  22.   currTime = currTime + inc
  23.   if currTime > maxTime then
  24.     timeUp()
  25.   else
  26.     timepercent = currTime / maxTime * 100
  27.     newlegth = clockLength / 100.0 * timepercent
  28.     sprite(clockSprite).locV = startV + newlegth
  29.   end if
  30. end
  31.  
  32. on stopClock
  33.   inc = 0
  34.   timeout("ClockTick").forget()
  35. end
  36.  
  37. on timeUp
  38.   stopClock()
  39.   endGame("timesup")
  40. end
  41.  
  42. on pauseClock
  43.   inc = 0
  44. end
  45.