TGC Codebase Backup



Another 12 hours clock by exLRT

19th Jul 2004 5:52
Summary

Just another 12 hours clock...made up a set of spheres



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: 3DClocks
Rem Created: 13/07/2004 08:34:18
Rem Author: Ulric Boël (ulric.boel@pro.tiscali.be)

Rem ***** Main Source File *****

rem set display mode 1024,768,32
sync on
autocam off
set text font "Arial"
set text size 24

global defaultRadius# = 15.0
global baseTick = 1
global currentTick = baseTick
global turnRate# = 6.0
global cFPS = 0

colClock = rgb(255, 255, 255)
colHNeedle = rgb(64, 128, 255)
colMNeedle = rgb(128, 128, 255)
colSNeedle = rgb(255, 0, 0)

position camera 0, 0.0, 0.0, -35.0
point camera 0, 0.0, 0.0, 0.0

gosub initObjects
while not escapekey()
   gosub mainLoop
   sync;
endwhile

return

rem ------------------------------------------------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------------------------------------------------
initObjects:
   rem --- Clock ---
   make object sphere 1, 1.0
   make mesh from object 1, 1
   for i=0 to 59
      thisTick = baseTick+i
      add limb 1,thisTick,1

      tickX# = defaultRadius# * sin(i*6)
      tickY# = defaultRadius# * cos(i*6)
      offset limb 1, thisTick, tickX#, tickY#, 0.0
   next i
   delete mesh 1
   color object 1, colClock

   rem --- Hours needle ---
   make object sphere 2, 0.6
   make mesh from object 1, 2
   for i = 1 to 13
      add limb 2, i, 1
      offset limb 2, i, 0.0, i, 0.0
   next i
   color object 2, colHNeedle
   delete mesh 1


   rem --- Minutes needle ---
   make object sphere 3, 0.8
   make mesh from object 1, 3
   for i = 1 to 7
      add limb 3, i, 1
      offset limb 3, i, 0.0, i, 0.0
   next i
   color object 3, colMNeedle
   delete mesh 1

   rem --- Seconds needle ---
   make object sphere 4, 0.3
   make mesh from object 1, 4
   for i = 1 to 26
      add limb 4, i, 1
      offset limb 4, i, 0.0, i/2.0, 0.0
   next i
   color object 4, colSNeedle
   delete mesh 1



return
rem ------------------------------------------------------------------------------------------------------------------------
mainLoop:
   theHour$ = get time$()
   theH = val(mid$(theHour$,1)+mid$(theHour$,2))
   theM = val(mid$(theHour$,4)+mid$(theHour$,5))
   theS = val(mid$(theHour$,7)+mid$(theHour$,8))

   if currentTick-baseTick <> theS
      color limb 1, currentTick, colClock
      currentTick = baseTick + theS
      color limb 1, currentTick, colSNeedle
   endif

   theHAngle# = (theH mod 12) * 30.0
   rotate object 3, 0.0, 0.0, -theHAngle#

   theMAngle# = theM * 6.0
   rotate object 2, 0.0, 0.0, -theMAngle#

   theSAngle# = theS * 6.0
   rotate object 4, 0.0, 0.0, -theSAngle#

   center text screen width()/2,screen height()- 50,theHour$

return
rem ------------------------------------------------------------------------------------------------------------------------
rem ------------------------------------------------------------------------------------------------------------------------