How to get a zero

Blitz3D Forums/Blitz3D Programming/How to get a zero

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Something like this? Dodgy key choice btw ;)

;My Code
Graphics3D 640, 480, 0, 2

CAM = CreateCamera()
MoveEntity CAM, 0, 80, 0
TurnEntity CAM, 90, 0, 0

Global PLAYER_VX# , PLAYER_VZ#
Const PLAYER_DRAG# = .9866
Const PLAYER_ACC# = .01
Global PLAYER_SPEED#
;NOTE: Max Speed = PLAYER_ACC / ( 1.0 - PLAYER_DRAG )

Global PLAYER_MESH
PLAYER_MESH = CreateCone()
RotateMesh PLAYER_MESH, 90,0,0 : ScaleMesh PLAYER_MESH, 1, 1, 2
EntityFX PLAYER_MESH, 1

Create_Grid(32)


Repeat
	
	Move_Player()
	
	DebugLog PLAYER_SPEED#
	
	RenderWorld()
	Text 0, 0, "Speed: " + PLAYER_SPEED#
	Flip 

Until KeyHit(1)
End



Function Move_Player()


	Turn = KeyDown(30) - KeyDown(32)
	TurnEntity PLAYER_MESH, 0, Turn , 0

	Acceleration# = ( KeyDown(17) - KeyDown(31) ) * PLAYER_ACC
	TFormVector 0, 0, Acceleration, PLAYER_MESH, 0
		
	PLAYER_VX = ( PLAYER_VX * PLAYER_DRAG ) + TFormedX()
	PLAYER_VZ = ( PLAYER_VZ * PLAYER_DRAG ) + TFormedZ()
	PLAYER_SPEED# = Sqr( PLAYER_VX * PLAYER_VX + PLAYER_VZ * PLAYER_VZ ) 
	
	If Acceleration = 0 And PLAYER_SPEED < .001
		PLAYER_VX = 0
		PLAYER_VZ = 0
	EndIf
	
	TranslateEntity PLAYER_MESH, PLAYER_VX, 0, PLAYER_VZ

End Function


Function Create_Grid(scale=1, size=256)
	
	GRIDTex = CreateTexture(size, size,1+2+8)
	SetBuffer TextureBuffer(GRIDTex)
	
	Color 0, 255, 0
	Rect 0, 0, size, size, 0
	Color 50, 50, 50
	Rect 1, 1, size-2, size-2, 1
	
	SetBuffer BackBuffer()
	ScaleTexture GRIDTex, scale, scale
	
	GRID = CreatePlane()
	EntityTexture GRID, GRIDTex
	
	EntityAlpha GRID, .75
	Color 255, 255, 255
End Function