TGC Codebase Backup



A Simple Clock by Alexb Orsova

6th Dec 2005 21:15
Summary

A Simple Clock. Uses Spheres for Hands and Cubes for Hour Markers. Please tell me what you think.



Description

A Simple Clock. Uses Spheres for Hands and Cubes for Hour Markers.
Please tell me what you think.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem Prepare Environment
hide mouse : color backdrop RGB(0, 0, 0)
sync on : sync rate 0 : draw to front

rem Loading Propmt
cls : center text screen width() / 2, screen height() / 2, "LOADING" : sync

rem Create Hour Markers
for t = 1 to 12
 make object cube t, 6
 position object t, 0, 0, 0
 yrotate object t, wrapvalue(t * 30)
 move object t, -100
 color object t, RGB(255, 255, 255)
next t

rem Create Hour, Minute adn Second spheres
make object sphere 13, 12
color object 13, RGB(0, 0, 255)
make object sphere 14, 8
color object 14, RGB(0, 255, 0)
make object sphere 15, 4
color object 15, RGB(255, 0, 0)
make object sphere 16, 6
position object 16, 0, 0, 0
color object 16, RGB(255, 255, 0)

rem Position Camera
position camera 0, 180, 0
point camera 0, 0, 0

rem Main Loop
Do

 rem Get Time
 time$ = get time$()

 rem hour ball
 position object 13, 0, 0, 0
 yrotate object 13, wrapvalue((hours(time$) * 30) + 180)
 move object 13, -85

 rem minute ball
 position object 14, 0, 0, 0
 yrotate object 14, wrapvalue((minutes(time$) * 6) + 180)
 move object 14, -65

 rem second ball
 position object 15, 0, 0, 0
 yrotate object 15, wrapvalue((seconds(time$) * 6) + 180)
 move object 15, -45

 rem Update Screen
 sync

Loop

rem Wrap Value
function wrap(value, wv)
 while value >= wv
  value = value - wv
 endwhile
 retval = value
endfunction retval

rem Gets the Current Second
function seconds(string$)
 temp$ = mid$(string$, 7)
 temp$ = temp$ + mid$(string$, 8)
 value = val(temp$)
endfunction value

rem Gets the Current Minute
function minutes(string$)
 temp$ = mid$(string$, 4)
 temp$ = temp$ + mid$(string$, 5)
 value = val(temp$)
endfunction value

rem Gets the Current Hour
function hours(string$)
 temp$ = mid$(string$, 1)
 temp$ = temp$ + mid$(string$, 2)
 value = wrap(val(temp$), 13)
endfunction value