TGC Codebase Backup



Flat earth Sun and Moon rotation demo. by Mark Garrett

6th Dec 2015 19:05
Summary

Shows how the Sun and Moon move around the Arctic center of the flat earth each 24 hour day. The Sun, of course, moves completely in 24 hrs. And the moon takes aprox. 24.12 hrs...



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem Prepare Environment   (1400 x 1050)
hide mouse : color backdrop RGB(0, 0, 0)
create bitmap 1,786,881
`    load bitmap "Final Draft.bmp",1  `786 X 881
get image 1,0,0,786,881
set current bitmap 0



sync on : sync rate 50 : draw to front

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

make object plain map, 800,800

texture object map,1

position object map, -4,-600,3


xrotate object map,270
rem Create Hour Markers
for t = 100 to 124
 make object cube t, 6
 position object t, 0, 0, 0
 yrotate object t, wrapvalue(t * 15)
 move object t, -100
 color object t, RGB(255, 255, 255)
next t

rem Create Sun, Moon and Arctic Spheres

make object sphere 14, 8
color object 14, RGB(255, 255, 0)` Sun
make object sphere 15, 8
color object 15, RGB(222, 222, 222) `Moon
make object sphere 16, 6
position object 16, 0, 0, 0
color object 16, RGB(0, 0, 255) `Arctic

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


Start_or_restart: sunpos = 0: moonpos# = 0
rem Main Loop   `__________________________________

day# = 1
Do

rem speed up animation here
for x = 1 to 4
sunpos = sunpos +1: if sunpos = 360 then sunpos = 0: day# = day# + 1
If day# = 32 then day# = 1
month$ = "January"
set cursor 150,80: print month$," ", day#

set text size 12: set cursor 20,20: print "to stop- press Escape key (esc key upper left keyboard)"

rem the moon lags behind the sun, but then lines up with it again 27.32 (star alignment) days later. Therefore:
rem   100(1 hour)-  /27.32  =  100-3.66  =  96.34

moonpos# = moonpos# + .9634 : if moonpos# > 360 then moonpos# = 0


next x



 rem Sun ball
 position object 14, 0, 0, 0
 yrotate object 14, sunpos   +180
 move object 14, -45

 rem moon ball
 position object 15, 0, 0, 0
 yrotate object 15, moonpos#   +180
 move object 15, -35

 rem Update Screen
 if SPACEKEY()= 1 then goto start_or_restart


Rem put date



 sync
if firstime = 0 then sync: sleep 5000 : firstime = 1 `(show start position)
Loop