text acceleration and velocity?

Blitz3D Forums/Blitz3D Beginners Area/text acceleration and velocity?

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.

The friction thing could be coded better. But to make there be less friction, use a higher number from 0 to 1.

Right now it is at .8
change it to .95 to make it a lot smoother

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

Global Light = CreateLight()
	
	
Global Camera = CreateCamera()
	PositionEntity Camera,0,2,-5
	
CreatePlane()


Global Pivot = CreatePivot()
Global cube = CreateCube(Pivot)
	EntityColor cube,0,255,0

Global X_Velo#,X_Accel#,X_Frict#=.8
Global Y_Velo#,Y_Accel#,Y_Frict#=.8
Global Z_Velo#,Z_Accel#,Z_Frict#=.8
Global Speed#

While Not KeyDown(1)
	
	If KeyDown(200) Z_Accel = .1
	If KeyDown(208) Z_Accel = -.1
	
	If KeyDown(203) X_Accel = -.1
	If KeyDown(205) X_Accel = .1
	
	TempX# = X_Accel
	TempZ# = Z_Accel
	
	MovePlayer()
	UpdateWorld
	RenderWorld
	
	Text 0,0,"X Velocity = " + X_Velo
	Text 0,20,"Y Velocity = " + Y_Velo
	Text 0,40,"Z Velocity = " + Z_Velo
	
	Text 0,80,"X Acceleration = " + X_Accel
	Text 0,100,"Y Acceleration = " + Y_Accel
	Text 0,120,"Z Acceleration = " + Z_Accel
	Text 0,140,"You won't be able to see the acceleration since it is set back to 0 each 'MovePlayer' loop"
	Text 0,160,"Instead you could use a temporary variable..."
	
	Text 0,200,"TempX = " + TempX
	Text 0,220,"TempZ = " + TempZ
	
	
	Flip
	
Wend
End

Function MovePlayer()
	X_Velo = X_Velo + X_Accel
	Y_Velo = Y_Velo + Y_Accel
	Z_Velo = Z_Velo + Z_Accel
	
	TranslateEntity Pivot,X_Velo,Y_Velo,Z_Velo
	
	X_Velo = X_Velo * X_Frict
	Y_Velo = Y_Velo * Y_Frict
	Z_Velo = Z_Velo * Z_Frict
		
	Speed = Sqr( (X_Velo*X_Velo) + (Y_Velo*Y_Velo) + (Z_Velo*Z_Velo) )
	
	X_Accel = 0
	Y_Accel = 0
	Z_Accel = 0
End Function