TGC Codebase Backup



3d planets revolving around sun by pollywog

18th Nov 2008 0:03
Summary

3d planets revolve around the sun. move with arrow keys or press 1,2,3 etc to lock onto a planet I got all the textures from http://planetpixelemporium.com/mercury.html the rest of



Description

get the planet textures from http://planetpixelemporium.com/mercury.html
for all other media I just took the media folder out of the face demo I needed that for the fire animation on the sun. I also added the sky in the media folder from the planet potter. both of these folders should be in your dark basic project folder already so just copy them out or reference them.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: space
Rem Created: 11/6/2008 1:58:23 PM

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

#CONSTANT SUN = 1 : #CONSTANT MERCURY = 2 : #CONSTANT VENUS = 3 : #CONSTANT EARTH = 4 : #CONSTANT MARS = 5 : #CONSTANT JUPITER = 6
#CONSTANT SATURN = 7 : #CONSTANT URANUS = 8: #CONSTANT NEPTUNE = 9 : #CONSTANT PLUTO  = 10



DIM Size#(10)
Size#(1)=100 : Size#(2)=10 : Size#(3)=20 : Size#(4)=20 : Size#(5)=20 :  Size#(6)=40
Size#(7)=30 : Size#(8) = 30 : Size#(9) = 30 : Size#(10) = 10

DIM DistanceFromSun(10)
DistanceFromSun(1) = 0
DistanceFromSun(2)=60 : DistanceFromSun(3)=90 : DistanceFromSun(4)=120 : DistanceFromSun(5)=150 : DistanceFromSun(6)=180
DistanceFromSun(7)=210 :DistanceFromSun(8)=240 : DistanceFromSun(9) = 270 : DistanceFromSun(10) = 300

DIM Angle#(10)
Angle#(1) = 0
Angle#(2)=60 : Angle#(3)=90 : Angle#(4)=120 : Angle#(5)=150 : Angle#(6)=180
Angle#(7)=210 :Angle#(8)=240 : Angle#(9) = 270 : Angle#(10) = 270

DIM x#(10) : DIM z#(10)



set display mode 1280, 1024, 32
color backdrop 0
backdrop on


load image "suntexture.jpg",1
load image  "mercurytexture.jpg",2
load image  "venustexture.jpg",3
load image  "earthtexture.jpg",4
load image  "marstexture.jpg",5
load image  "jupitertexture.jpg",6
load image  "saturntexture.jpg",7
load image  "uranustexture.jpg",8
load image  "neptunetexture.jpg",9
load image  "plutotexture.jpg",10
load image  "saturnringtexture.jpg",11

rem Load environment
load object "mediamoonlitml.x",100
scale object 100,20,20,20
set object cull 100,0
set object light 100,0
set object texture 100,2,1

rem Load fire animation
for ff=0 to 10
 load image "mediafirefire"+str$(10000+ff)+".tga",301+ff
next ff
anim=301

rem create the sun and planets
FOR n = 1 to 10
     make object sphere n,Size#(n),100,100
     texture object n,n
     if n = 1 then set object emissive n, rgb(255,0,0)
     if n > 1 then set object specular n,10
next n

rem make the ring around saturn
make object cylinder 11, 40
scale object 11,100,5,100
make mesh from object 1, 11
delete object 11
add limb 7,1,1
texture limb 7,1,11



autocam off
position camera 0,10,-350
rem put a light in the middle of the sun
make light 1
set point light 1,0,0,0
color light 1, rgb(255,255,255)

do
   for n = 1 to 10
       if n > 1
         rem rotate the planets around the sun
         x#(n) = COS(Angle#(n))*DistanceFromSun(n)
         z#(n) = SIN(Angle#(n))*DistanceFromSun(n)
         position object n, x#(n), 0, z#(n)
         rem spin the planets
         turn object left n,0.2
        Angle#(n) = Angle#(n) + ((11 - n) * .1)
      endif
next n

 rem Flame animation in sun
 atimer = atimer + 1
 if atimer > 5
   texture object 1,anim
   set sphere mapping on 1,1
   inc anim : if anim>311 then anim=301
   atimer = 0
 endif

charhit$ = inkey$()
if charhit$ = chr$(49)
   position camera 0,0,-100
   point camera 0,0,-100
endif
for n = 2 to 10
   if charhit$ = chr$(48+n)
      position camera x#(n), 0, z#(n)-30
      point camera x#(n), 0, z#(n)-30
   endif
clear entry buffer
next n

control camera using arrowkeys 0, 3,3



loop