No, you are right - I patched up the rotation bug he mentioned and ran it, and it didn't behave like asteroids, but only because pds is too big. It just looked like the ship was accelerating from zero rather than fighting against its previous motion everytime I rotated and thrusted... scale down pds, though, and it becomes clear that it is behaving as you'd expect. So my bad on that one and sorry if I sounded a bit patronising - shoulda' looked more thoroughly at what his code was doing.
I still think, where speed-capping is concerned, it makes more sense to stop thinking in terms of pds as a speed constant and replace it with a variable amount of thrust. As things stand he's going to have to cap pdx and pdy separately, so the ship is going to have a higher top speed diagonally (with max pdx and max pdy combined) than vertically (with max pdx alone) and horizontally (with max pdy alone). I still think a lot of the "action" is occuring on the wrong side of those Sin and Cos equations!
Anyway, my tweaks (no capping) are posted below - the new pds value shows things off a bit better and the pivot work might give Grant a few ideas, what with 'im being new to this 3D malarkey. Ooh also - don't Print, it shifts the display (debug with Text then either use a bitmap or sprite-based font system for release).
I still think, where speed-capping is concerned, it makes more sense to stop thinking in terms of pds as a speed constant and replace it with a variable amount of thrust. As things stand he's going to have to cap pdx and pdy separately, so the ship is going to have a higher top speed diagonally (with max pdx and max pdy combined) than vertically (with max pdx alone) and horizontally (with max pdy alone). I still think a lot of the "action" is occuring on the wrong side of those Sin and Cos equations!
Anyway, my tweaks (no capping) are posted below - the new pds value shows things off a bit better and the pivot work might give Grant a few ideas, what with 'im being new to this 3D malarkey. Ooh also - don't Print, it shifts the display (debug with Text then either use a bitmap or sprite-based font system for release).
;***INITIALIZATION***; Graphics3D 800,600,16,2 SetBuffer BackBuffer() SeedRnd MilliSecs() ;***VARIABLES***; Global pdx#, pdy# ;Player's direction in the 2 1/2D world Global px#, py# ;Player's coordinates Const pds# = 0.001 ; Player's speed ;***ENTITIES***; ;Camera Global cam = CreateCamera() CameraRange cam,1,1000 PositionEntity cam,0,10,0 RotateEntity cam,90,0,0 ;Spaceship Global ship = CreatePivot() shipmesh=CreateCone(8,True,ship);LoadMesh("fighter.3ds") ScaleEntity ship,.1,.1,.1 PositionEntity ship,0,0,0 RotateEntity shipmesh,90,0,0 ;Main Light light = CreateLight(1) RotateEntity light,90,0,0 ;Skybox skybox = CreateSphere() FlipMesh skybox skytex = CreateTexture(32,32);LoadTexture("stars.jpg") ScaleTexture skytex,.09,.09 EntityTexture skybox,skytex ScaleEntity skybox,500,500,500 PositionEntity skybox,0,50,0 EntityOrder skybox,1 ;***ARRAYS***; Dim astmesh(3) ;Big Asteroid astmesh(1) = CreateSphere(8);LoadMesh("asteroid.3ds") ScaleMesh astmesh(1),.1,.1,.1 RotateMesh astmesh(1),0,0,0 HideEntity astmesh(1) ;Medium Asteroid astmesh(2) = CopyMesh(astmesh(1)) ScaleMesh astmesh(2),.5,.5,.5 HideEntity astmesh(2) ;Little Asteroid astmesh(3) = CopyMesh(astmesh(2)) ScaleMesh astmesh(3),.5,.5,.5 HideEntity astmesh(3) ;***TYPES***; Type asteroid Field x#,y# ;Asteroid's position in the 2 1/2D world Field mesh ;Asteroid's mesh Field vx#,vy# ;Asteroid's x and y velocities End Type ;Game Initialization Functions CreateAsteroids() ;MAIN LOOP While Not KeyHit(1) TestInput() UpdateShip() UpdateAsteroids() UpdateWorld RenderWorld ;Print pdx# ;Print pdy# Flip Wend End ;***FUNCTIONS*** Function TestInput() If KeyDown(203) TurnEntity ship,0,2,0 Else If KeyDown(205) TurnEntity ship,0,-2,0 End If If KeyDown(200) AsteroidPhysics() End If End Function Function CreateAsteroids() For i = 1 To 3 a.asteroid = New asteroid a\x# = 0 a\y# = 0 a\mesh = CopyMesh(astmesh(1)) a\vx# = Rnd(-.1,.1) a\vy# = Rnd(-.1,.1) Next End Function Function UpdateAsteroids() For a.asteroid = Each asteroid a\x# = a\x# + a\vx# a\y# = a\y# + a\vy# If a\x# > 15 a\x# = -15 Else If a\x# < -15 a\x# = 15 End If If a\y# > 15 a\y# = -15 Else If a\y# < -15 a\y# = 15 End If PositionEntity a\mesh,a\x,0,a\y# Next End Function Function AsteroidPhysics() pdx# = pdx# + Sin(-EntityYaw#(ship))*pds# pdy# = pdy# + Cos(EntityYaw#(ship))*pds# End Function Function UpdateShip() px# = px# + pdx# py# = py# + pdy# PositionEntity ship,px#,0,py# End Function