Hi,
I recently stumbled on this coding
http://forum.thegamecreators.com/?m=forum_view&t=61145&b=7
which enabled me to create a moving sphere around a textured sun. My question is to create multiple spheres moving around the sun at different radiuses and speed, could it be used with storing values in arrays?
currently the coding looks like this.
`credits
`---------------------
`FPS Gun Movement Demo By Joseph Thomson
`Sun / planet rotation / movement By TDK Man
`Texutures by Scraggle's various packs
`Setup
SYNC ON : SYNC RATE 60
SET DISPLAY MODE 1280,1024,32
set camera range 1, 200000
color backdrop rgb(0,0,0)
`Turn off all default light
set ambient light 0
color light 0,rgb(0,0,0)
`Make the sunlight
make light 1
set point light 1,10000,1000,10000
`set point light 1,500,0,0
set light range 1,10000000000
color light 1,rgb(255,255,255)
HIDE MOUSE
` global vertex sharing
SET GLOBAL object creation 1
`SET DIR "media"
`loading images
load image "media\earth like\Light mapped texture.png",1
load image "media\sun\sunmap.jpg",2
`Set gun holding-limb position
gunOffsetX AS FLOAT = 15.0
gunOffsetY AS FLOAT = -20.0
gunOffsetZ AS FLOAT = 20.0
`Make main player object and hide it
MAKE OBJECT CUBE 1,10
HIDE OBJECT 1
`Attach a limb and delete the mesh
MAKE MESH FROM OBJECT 1,1
ADD LIMB 1,1,1
DELETE MESH 1
`Make a weapon and attach it to the limb
MAKE OBJECT BOX 2,10,10,100
GLUE OBJECT TO LIMB 2,1,1
`Make matrix to walk on
MAKE MATRIX 1,10000,10000,100,100
`Variables
xPos AS FLOAT
zPos AS FLOAT
speed AS FLOAT = 10.0
xLook AS FLOAT
yAng AS FLOAT
lookSpeed AS FLOAT = 0.2
`The gun bobbing values
gunBobSpeed AS FLOAT = 6.0
gunBobMove AS FLOAT = 3.0
gunBobHeight AS FLOAT = 1.5
gunBobAng AS FLOAT
gunTurnAng AS FLOAT
gunLookAng AS FLOAT
angleinc AS FLOAT
Radius# AS FLOAT
mouseMovementX AS FLOAT
mouseMovementY AS FLOAT
`radiuses
Radius#=50000.0: AngleInc=.2: Rem Speed of rotation
XDist#=Radius#: XDistInc=0-AngleInc
ZDist#=Radius#: ZDistInc=AngleInc
`sun
MAKE OBJECT sphere 4,1000,100,100
TEXTURE OBJECT 4,2
SET OBJECT AMBIENT 4,0
set object transparency 4,4
`SCALE OBJECT 4,10000,10000,10000
POSITION OBJECT 4,10000,1000,10000
`test planet
make object sphere 3,500,100,100
SCALE OBJECT 3,1000,1000,1000
TEXTURE OBJECT 3,1
POSITION OBJECT 3,1000,100,1000
`test planet 2
make object sphere 5, 1000,100,100
SCALE OBJECT 5,1000,1000,1000
set object ambient 4,0
DO
gosub playermovement_
gosub planetmovement_
gosub planetmovementrotationsun_
SYNC
LOOP
playermovement_:
`Store mouse movement
mouseMovementX = MOUSEMOVEX()
mouseMovementY = MOUSEMOVEY()
`Control movement using trig
IF keystate(17)+ keystate(31)+ keystate(30)+ keystate (32) > 0
IF keystate(17) = 1
INC xPos,SIN(yAng)*speed
INC zPos,COS(yAng)*speed
ENDIF
IF keystate(31) = 1
DEC xPos,SIN(yAng)*speed
DEC zPos,COS(yAng)*speed
ENDIF
IF keystate(32) = 1
INC xPos,COS(yAng)*speed
INC zPos,-SIN(yAng)*speed
ENDIF
IF keystate (30) = 1
DEC xPos,COS(yAng)*speed
DEC zPos,-SIN(yAng)*speed
ENDIF
`Increase gun-bobbing angle to get gun bobbing
gunBobAng = WRAPVALUE(gunBobAng+gunBobSpeed)
ELSE
`Otherwise slowly change the value to nothing to bring the gun to the centre again
gunBobAng = CURVEANGLE(0,gunBobAng,10)
ENDIF
`Control the gun swaying according to how much the player is turning
gunTurnAng = CURVEANGLE(WRAPVALUE(mouseMovementX),gunTurnAng,10)
gunLookAng = CURVEANGLE(WRAPVALUE(mouseMovementY),gunLookAng,10)
`Position the gun-holding limb and rotate it to give swaying effect
OFFSET LIMB 1,1,gunOffsetX+SIN(gunBobAng)*gunBobMove,gunOffsetY+ABS(COS(gunBobAng))*gunBobHeight,gunOffsetZ
ROTATE LIMB 1,1,gunLookAng,gunTurnAng,0
`Turn player
yAng = WRAPVALUE(yAng + mouseMovementX*lookSpeed)
xLook = WRAPVALUE(xLook + mouseMovementY*lookSpeed)
`Position player object and camera
POSITION OBJECT 1,xPos,100,zPos
ROTATE OBJECT 1,0,yAng,0
PITCH OBJECT DOWN 1,xLook
POSITION CAMERA xPos,100,zPos
ROTATE CAMERA xLook,yAng,0
planetmovement_:
test#=wrapvalue(test#+.1)
position object 3,cos(test#)*5000,1000,sin(test#)*5000
yROTATE OBJECT 3,test#
return
planetmovementrotationsun_:
X# = WrapValue(X# + AngleInc)
Z# = WrapValue(Z# + AngleInc)
If X#>359-AngleInc or Z#>359-AngleInc
Inc XDist#,XDistInc
If XDist#<=0-Radius#
XDist#=0-Radius#: XDistInc=AngleInc
YDist#=0.0: YDistInc=0-AngleInc
Endif
If XDist#>Radius#
XDist#=Radius#: XDistInc=0-AngleInc
YDist#=0.0: YDistInc=0-AngleInc
Endif
Endif
Position Object 5, newxvalue(10000,X#,XDist#),newyvalue(100,Y#,YDist#),newzvalue(10000,Z#,ZDist#)
return
LW
Hi!