TGC Codebase Backup



Solar System Recreation (No Media) by Doom

19th Mar 2006 22:26
Summary

A Solar System recreation from kevins original code, added all nine planets plus Texture commands and rotation for each planet.good for new comers. Uses Sin and Cos Math. Screensh



Description

A Solar System recreation from kevins original code, added all nine planets plus Texture commands and rotation for each planet.good for new comers. Uses Sin and Cos Math. try switching it around and try using tangent ;)

http://img56.imageshack.us/my.php?image=exper5na.png << Screen shot.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    cls:sync on:sync rate 300

`Solar system recreation
`coded by david cluett
`Based off the original code at
`http://darkbasic.thegamecreators.com/?m=codebase_view&i=8ebb6915246281328c25d09e93cd2a5e

`START-UP
ink rgb(255, 255, 255), 0
set text size 12
set text font "arial"
center text 320, 100, "Press the arrow keys to move around"
center text 320, 140, "Press 'a' and 's' to move camera up and down"
center text 320, 180, "have fun exploring the bore zone :D"
set text size 16
center text 320, 240, "Press any key to continue..."
suspend for key

`BACKDROP COLOR
backdrop on: color backdrop 0

`Precache -PUBLIC- FILES
`These functions load the textures for the planets
`Load image "sun.jpg",1 
`Load image "merc.jpg",2
`Load image "ven.jpg",3
`Load image "earth.jpg",4
`Load image "mars.jpg",5
`Load image "jupiter.jpg",6 
`Load image "saturn.jpg",7
`Load image "ura.jpg",8
`Load image "nep.jpg",9
`Load image "plut.jpg",10
`Planets
`Side note: to remove textures get rid of loading seq.
`and then the load seq. and replace it with the following
`color object (Object number), rgb(28, 28, 28) << Colour


`Mercury
make object sphere 5, 10
position object 5, 300, 0, 500
color object 5, rgb(28, 28, 28)

`Venus
make object sphere 4, 35
position object 4, 300, 0, 500
color object 4, rgb(28, 28, 28)

`Sun
make object sphere 1, 100
position object 1, 500, 0, 500
color object 1, rgb(255, 255, 0)
`Mars
make object sphere 6, 20
position object 6, 450, 0, 500
color object 6, rgb(255, 0, 0)
`Earth
make object sphere 2, 40
position object 2, 400, 0, 500
color object 2, rgb(0, 255, 0)
`Saturn
make object sphere 8, 50
position object 8, 600, 0, 600
color object 8, rgb(255, 255, 28)

`Moon
make object sphere 3, 4
position object 3, 410, 100, 550
color object 3, rgb(120, 120, 120)
`Jup
make object sphere 7, 60
position object 7, 500, 0, 500
color object 7, rgb(0, 28, 0)
`ura
make object sphere 9, 35
position object 9, 650, 0, 650
color object 9, rgb(28, 28, 28)
`nep
make object sphere 10, 40
position object 10, 700, 0, 700
color object 10, rgb(0, 228, 28)
`plut
make object sphere 11, 10
position object 11, 750, 0, 750
color object 11, rgb(28, 28, 28)




`loaded media
`These functions texture the spheres
`Texture object 1,1
`Texture object 5,2
`Texture object 4,3
`Texture object 2,4
`Texture object 6,5
`Texture object 7,6
`Texture object 8,7
`Texture object 9,8
`Texture object 10,9
`Texture object 11,10
`CAMERA STARTING POSITION
position camera 0, 0, 0

`VARIABLES
camy = 1
camx = 1

`MAIN LOOP

do
   set cursor 0,50
   `This Measures how many frames per second you are getting.
   print "FPS:",screen fps()
   `Here are the Rotation Equations for each planet around
   `the main sphere (its not in the right order but oh well
   `plut
   obj11x# = sin(1#) * 700 + 500
	obj11z# = cos(1#) * 700 + 500	
   1# = 1# + .1
   position object 11, obj11x#, 0, obj11z#
   `Merc
   obj5x# = sin(a#) * 100 + 500
	obj5z# = cos(a#) * 100 + 500	
   a# = a# + .9
   position object 5, obj5x#, 0, obj5z#
   `Venus
   obj4x# = sin(l#) * 150 + 500
	obj4z# = cos(l#) * 150 + 500	
   l# = l# + .8
   position object 4, obj4x#, 0, obj4z#
   `Jup
   obj7x# = sin(jup#) * 520 + 500
	obj7z# = cos(jup#) * 500 + 500	
   jup# = jup# + .5
   position object 7, obj7x#, 0, obj7z#
   
   `Sat
   obj8x# = sin(sat#) * 550 + 500
	obj8z# = cos(sat#) * 550 + 500	
   sat# = sat# + .4
   position object 8, obj8x#, 0, obj8z#
   `Mars
   obj6x# = sin(mars#) * 420 + 500
	obj6z# = cos(mars#) * 400 + 500
	mars# = mars# + .6
	position object 6, obj6x#, 0, obj6z#
  `ura
   obj9x# = sin(ura#) * 600 + 500
	obj9z# = cos(ura#) * 600 + 500
	ura# = ura# + .3
	position object 9, obj9x#, 0, obj9z#
  `nep
   obj10x# = sin(nep#) * 650 + 500
	obj10z# = cos(nep#) * 650 + 500
	nep# = nep# + .2
	position object 10, obj10x#, 0, obj10z#

   `Earth And Moon
	obj2x# = sin(n#) * 340 + 500
	obj2z# = cos(n#) * 300 + 500
	obj3x# = sin(m#) * 30 + obj2x#
	obj3z# = cos(m#) * 30 + obj2z#
	n# = n# + .7 : m# = m# + .5
	position object 2, obj2x#, 0, obj2z#
	position object 3, obj3x#, 0, obj3z#

   `Spinning the planets
   turn object right 1,.1
   turn object right 5,.2
   turn object right 4,.3
   turn object right 6,.4
   turn object right 7,.5
   turn object right 8,.6
   turn object right 9,.7
   turn object right 10,.8
   turn object right 2,.3
   turn object right 11,2
	`CAMERA COMMANDS
	if upkey()=1
		move camera 1
	endif
	if downkey()=1
		move camera -1
	endif
	if rightkey()=1
		camy = camy + 1
		yrotate camera camy
		if camy > 359 then camy = 1
	endif
	if leftkey()=1
		camy = camy - 1
		yrotate camera camy
		if camy < 1 then camy = 359
	endif
	if inkey$()="a"
		camx = camx + 1
		xrotate camera camx
		if camx > 359 then camx = 1
	endif
	if inkey$()="s"
		camx = camx - 1
		xrotate camera camx
		if camx < 1 then camx = 359
	endif

`LOOP
print "Solar System"
sync:loop