TGC Codebase Backup



Sun, Earth, moon by zodiac

15th Mar 2006 23:58
Summary

basic planet movement no media



Description

5 min. project, just wanted to make a quick planet program using sin and cos (instead of wrapvalue).



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

`===============================
`SUN, EARTH, AND MOON SIMULATION
`===============================
`*****CODED BY KEVIN FORBES*****
`===============================

`START-UP
ink rgb(250, 100, 20), 0
set text size 30
set text font "arial"
center text 320, 100, "Press the arrow keys to move around"
center text 320, 140, "Press 'a' and 's' to pitch camera"
center text 320, 180, "Enjoy!"
set text size 16
center text 320, 240, "Press any key to continue..."
suspend for key

`BACKDROP COLOR
backdrop on: color backdrop 0

`PLANET, SUN, MOON
`Sun
make object sphere 1, 100
position object 1, 500, 0, 500
color object 1, rgb(250, 0, 0)

`Earth
make object sphere 2, 40
position object 2, 400, 0, 500
color object 2, rgb(0, 0, 200)

`Moon
make object sphere 3, 10
position object 3, 410, 0, 500
color object 3, rgb(120, 120, 120)


`CAMERA STARTING POSITION
position camera 500, 50, 0

`VARIABLES
camy = 1
camx = 1

`MAIN LOOP
do

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

	`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
sync:loop