Rotating entity continuously

Blitz3D Forums/Blitz3D Beginners Area/Rotating entity continuously


What I want, is to push a button and my entity to get moving and rotate with a push of a button, and not have to hold the button down while it's moving or turning.



Then you need to initiate a variable to keep track of whether the object is supposed to be in motion/turning or not.

EDIT: Here, I would be thinking along these lines...
Graphics3D 800,600,0,2
SetBuffer BackBuffer()
cam=CreateCamera() : PositionEntity cam,0,2,-10

Type player
	Field key_up
	Field key_down
	Field key_left
	Field key_right
	Field key_center
	
	Field zVel#
	Field turningRate#
	
	Field entity
End Type
currentPlayer.player=Null

shipTemplate=CreateCube()
ScaleEntity shipTemplate,1,.1,5
HideEntity shipTemplate

oneUp.player=New player
oneUp\key_up = 200
oneUp\key_down = 208
oneUp\key_left = 203
oneUp\key_right = 205
oneUp\key_center = 57
oneUp\zVel=0.0
oneUp\turningRate=0.0
oneUp\entity=CopyEntity(shipTemplate)

cameraTarget.player=oneUp

ground=CreatePlane()
groundTex=CreateTexture(32,32,8)
ScaleTexture groundTex,2,2
Color 100,255,100
Line 0,0,31,0
Line 0,0,0,31
CopyRect 0,0,32,32,0,0,BackBuffer(),TextureBuffer(groundTex)
EntityTexture ground,groundTex


While Not KeyHit(1)

For currentPlayer=Each player
	If KeyDown(currentPlayer\key_up) Then currentPlayer\zVel=.1
	If KeyDown(currentPlayer\key_down) Then currentPlayer\zVel=0.0

	If KeyDown(currentPlayer\key_left) Then currentPlayer\turningRate=currentPlayer\turningRate+0.1
	If KeyDown(currentPlayer\key_right) Then currentPlayer\turningRate=currentPlayer\turningRate-0.1
	
	If currentPlayer\turningRate<-2 Then currentPlayer\turningRate=-2
	If currentPlayer\turningRate>2 Then currentPlayer\turningRate=2
	If KeyDown(currentPlayer\key_center) Then currentPlayer\turningRate=0.0
	
	TurnEntity currentPlayer\entity,0,currentPlayer\turningRate,0
	MoveEntity currentPlayer\entity,0,0,currentPlayer\zVel
Next


PointEntity cam,cameraTarget\entity
RenderWorld
Flip
Wend


Cursor keys + space (to center rudder).