text acceleration and velocity?

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

how would I make it so the velocity and acceleration shows up in text on the screen? Is there certain code for physics?

edit:

I'm sorry, the acceleration and velocity of a truck in my program. I want to find a way to find the acceleration and velocity...

I think you need to explain yourself a bit better.

The velocity and acceleration of what exactly? Do you need to calculate the acceleration or velocity or do you have that information already? If you do then just print them to the screen using the text command after renderworld ( assuming 3d ) and before flip.

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



I'm sorry, the acceleration and velocity of a truck in my program. I want to find a way to find the acceleration and velocity...



Are you using a 3rd party physics engine or your own? If 3rd party then there will be commands to retrieve velocity and you should be able to derive the acceleration from the forces which are applied.

If it's your own engine then you should be doing something similar to GIA's code so will know these already.

It might be best for you to post some code.