does anyone have some code in which I can get multiple instances of an asteroid to bounce off each other? This is my code so far:
Graphics3D 640,480,16,1
SetBuffer BackBuffer()
SeedRnd (MilliSecs())
camera=CreateCamera ()
mainlight=CreateLight()
LightColor mainlight,255,255,10
sublight=CreateLight()
LightColor sublight,-255,-255,-255
indlight=CreateLight()
LightColor indlight,255,0,255
point=CreatePivot()
PositionEntity camera,0,100,0
PositionEntity mainlight,0,0,100
PositionEntity sublight,0,5,-0
PositionEntity indlight,0,0,-100
PositionEntity point,0,0,0
PointEntity camera,point
PointEntity mainlight,point
PointEntity sublight,point
PointEntity indlight,point
CameraViewport camera,0,0,viewx,viewy
Const viewx=800,viewy=600
Type asteroid
Field aster
Field x#
Field y#
Field z#
Field speedx#
Field speedz#
Field spin#
Field life
Field distance#
End Type
;rockskin=LoadTexture("images/rocktext.bmp")
rock=LoadMesh("images/rock1a.3ds")
HideEntity rock
For n=0 To 9
ast.asteroid=New asteroid
ast\aster=CopyEntity(rock)
ast\x#=Rnd(-50,50)
ast\y#=0
ast\z#=Rnd(-50,50)
ast\speedx#=Rnd(-.2,.2)
ast\speedz#=Rnd(-.2,.2)
ast\spin# = Rnd(-0.5,0.5)
ast\life=5
PositionEntity ast\aster,ast\x#,ast\y#,ast\z#
RotateEntity ast\aster,0,Rnd(0,359),0
ScaleEntity ast\aster,.5,.5,.5
mark=mark+1
Next
;Main Loop-----------------
While Not KeyHit(1)
;Cls
asteroidism()
UpdateWorld
RenderWorld
Flip
Wend
End
Function asteroidism()
For ast.asteroid=Each asteroid
TurnEntity ast\aster,ast\spin#,ast\spin#,ast\spin#
TranslateEntity ast\aster,ast\speedx#,0,ast\speedz#
If EntityZ#(ast\aster)>100
PositionEntity ast\aster,ast\x#,ast\y#,-100
EndIf
If EntityX#(ast\aster)>120
PositionEntity ast\aster,-120,ast\y#,ast\z#
EndIf
If EntityZ#(ast\aster)<-100
PositionEntity ast\aster,ast\x#,ast\y#,100
EndIf
If EntityX#(ast\aster)<-120
PositionEntity ast\aster,120,ast\y#,ast\z#
EndIf
Next
End Function
I can't seem to get it. Any help is of course much appreciated.
Graphics3D 640,480,16,1
SetBuffer BackBuffer()
SeedRnd (MilliSecs())
camera=CreateCamera ()
mainlight=CreateLight()
LightColor mainlight,255,255,10
sublight=CreateLight()
LightColor sublight,-255,-255,-255
indlight=CreateLight()
LightColor indlight,255,0,255
point=CreatePivot()
PositionEntity camera,0,100,0
PositionEntity mainlight,0,0,100
PositionEntity sublight,0,5,-0
PositionEntity indlight,0,0,-100
PositionEntity point,0,0,0
PointEntity camera,point
PointEntity mainlight,point
PointEntity sublight,point
PointEntity indlight,point
CameraViewport camera,0,0,viewx,viewy
Const viewx=800,viewy=600
Type asteroid
Field aster
Field x#
Field y#
Field z#
Field speedx#
Field speedz#
Field spin#
Field life
Field distance#
End Type
;rockskin=LoadTexture("images/rocktext.bmp")
rock=LoadMesh("images/rock1a.3ds")
HideEntity rock
For n=0 To 9
ast.asteroid=New asteroid
ast\aster=CopyEntity(rock)
ast\x#=Rnd(-50,50)
ast\y#=0
ast\z#=Rnd(-50,50)
ast\speedx#=Rnd(-.2,.2)
ast\speedz#=Rnd(-.2,.2)
ast\spin# = Rnd(-0.5,0.5)
ast\life=5
PositionEntity ast\aster,ast\x#,ast\y#,ast\z#
RotateEntity ast\aster,0,Rnd(0,359),0
ScaleEntity ast\aster,.5,.5,.5
mark=mark+1
Next
;Main Loop-----------------
While Not KeyHit(1)
;Cls
asteroidism()
UpdateWorld
RenderWorld
Flip
Wend
End
Function asteroidism()
For ast.asteroid=Each asteroid
TurnEntity ast\aster,ast\spin#,ast\spin#,ast\spin#
TranslateEntity ast\aster,ast\speedx#,0,ast\speedz#
If EntityZ#(ast\aster)>100
PositionEntity ast\aster,ast\x#,ast\y#,-100
EndIf
If EntityX#(ast\aster)>120
PositionEntity ast\aster,-120,ast\y#,ast\z#
EndIf
If EntityZ#(ast\aster)<-100
PositionEntity ast\aster,ast\x#,ast\y#,100
EndIf
If EntityX#(ast\aster)<-120
PositionEntity ast\aster,120,ast\y#,ast\z#
EndIf
Next
End Function
I can't seem to get it. Any help is of course much appreciated.