Asteroids thrust and rotation in 3D
Blitz3D Forums/Blitz3D Programming/Asteroids thrust and rotation in 3D
| ||
I am making an asteroids style game using 3D graphix (3D ship, Asteroids, Baddies, etc.) Does any one know how to program the thrust and rotation of the ship, the way it slides through space while rotating until you hit thrust? Any help will be appreciated. Thanks. |
| ||
Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() tex=LoadTexture( "terrain1.jpg") ScaleTexture tex,1000.0,1000.0 brush=CreateBrush() BrushTexture brush,tex plane=CreatePlane(8) PaintEntity plane,brush PositionEntity camera,0.0,50.0,0.0 RotateEntity camera,90,0.0,0.0 dist#=0.1 x#=0 y#=0 z#=0 While Not KeyDown( 1 ) If KeyDown( 203 )=True Then angle#=angle#+1.0 If KeyDown( 205 )=True Then angle#=angle#-1.0 If KeyDown( 200 )=True Then x#=x#+Cos(angle#+90.0)*dist# z#=z#+Sin(angle#+90.0)*dist# EndIf RotateEntity camera,0.0,angle#,0.0 TranslateEntity camera,x#,0.0,z# RenderWorld Text 0,20,"X Position: "+x# Text 0,40,"Y Position: "+y# Text 0,60,"Z Position: "+z# Flip Wend End Andy |
| ||
Thanks Andy, works like a charm! |
| ||
Yeah, knew it would... Andy |
| ||
X's and O's ;) @ Andy's sig. |
| ||
Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() CameraRange camera,1,5000000.0 light=CreateLight() tex=LoadTexture( "terrain1.jpg") ScaleTexture tex,1000.0,1000.0 brush=CreateBrush() BrushTexture brush,tex plane=CreatePlane(8) PaintEntity plane,brush PositionEntity camera,0.0,50.0,0.0 RotateEntity camera,0.0,0.0,0.0 dist#=0.1 anglex#=0 angley#=0 anglez#=0 x#=0 y#=0 z#=0 While Not KeyDown( 1 ) anglex#=0 angley#=0 anglez#=0 If KeyDown( 200 )=True Then anglex#=anglex#+1.0 If KeyDown( 208 )=True Then anglex#=anglex#-1.0 If KeyDown( 44 )=True Then angley#=angley#+1.0 If KeyDown( 45 )=True Then angley#=angley#-1.0 If KeyDown( 203 )=True Then anglez#=anglez#+1.0 If KeyDown( 205 )=True Then anglez#=anglez#-1.0 If KeyDown( 57 )=True Then x#=x#+Cos(EntityYaw(camera)+90.0)*dist# z#=z#+Sin(EntityYaw(camera)+90.0)*dist# y#=y#+Cos(EntityPitch(camera)+90.0)*dist# EndIf TurnEntity camera,anglex#,angley#,anglez# TranslateEntity camera,x#,y#,z# RenderWorld Text 0,20,"X: "+x# Text 0,40,"Y: "+y# Text 0,60,"Z: "+z# Text 0,80,"X Position: "+EntityX(camera) Text 0,90,"Y Position: "+EntityY(camera) Text 0,110,"Z Position: "+EntityZ(camera) Flip Wend End Try this instead, it's fully 3D, and could form the basis for a network shootemup. Arrowkeys, z+x, space used to control the camera. Andy |