PhysLite accelerate-deAccelerate

BlitzMax Forums/BlitzMax Programming/PhysLite accelerate-deAccelerate

verfum(Posted 2008) [#1]
Does anyone know how to accelerate and de-accelerate an object in zero gravity in PhysLite? As in Example2 which is a top down asteroids example, I'd like it so when you release the UP key the vessel slows down until stopped, but I haven't got a clue how? I've tried this but it totally screws the physics up!
	m_angle = m_body.GetRotation() 
	m_x:Float = Cos(m_angle) * m_speed;
	m_y:Float = Sin(m_angle) * m_speed;
			
	If KeyDown(KEY_LEFT) Then m_body.Spin -.1
	If KeyDown(KEY_RIGHT) Then m_body.Spin +.1
				
	If KeyDown(KEY_UP) Then
	        m_speed:+0.01;
	Else
		m_speed:*0.09;
	EndIf
		
	m_body.MassSetVelocity(index, m_x, m_y) ;



Oddball(Posted 2008) [#2]
I've posted a full example over at the PhysLite forum, but I'll repeat the important bit here.
For Local index:Int=0 To ship.MassMaxIndex()
	ship.MassSetVelocity index,ship.MassGetVX(index)*.97,ship.MassGetVY(index)*.97
Next