Hey guys,
The problem is that when i rotate(left/right key) my ship i’m getting acceleration which should only occur when the thruster is firing(up Key).
I’m using a standard motion model and im using it in a model view controller pattern which may or may not be the problem.
Here’s the movement model and I would be happy to email you the swf:
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
public class AsteroidSupplyMovementModel extends EventDispatcher
{
private var _rotation:Number=0;
private var _rVel:Number=0;
private var _yAcc:Number=0;
private var _angle:Number=0;
private var _thrust:Number=0;
private var _gravity:Number=.098;
private var _xAcc:Number=0;
private var _yVel:Number=0;
private var _xVel:Number=0;
public function AsteroidSupplyMovementModel():void
{
}
public function update():void
{
_rotation += _rVel; //increases\decreses rotation(from keyboard)
if(Math.abs(_rVel)<.03)//rVelSpeedTrap;
{
_rVel=0;
}
_angle=_rotation*(Math.PI/180);
_yAcc=Math.cos(_angle) * _thrust;//+_gravity;//thrust+gravity;
_xAcc=Math.sin(_angle) * _thrust;
_yVel +=_gravity;
_yVel+=_yAcc;
_xVel-=_xAcc;
_yVel =_yVel*.98;
_rVel =_rVel*.8;
}
public function get rVel():Number
{
return(Math.ceil( _rVel));
}
public function set rVel(value:Number):void
{
_rVel = Math.ceil(rVel);
_rVel = value;
dispatchEvent(new Event(Event.CHANGE));
}
public function get thrust():Number
{
return _thrust;
}
public function set thrust(value:Number):void
{
_thrust = value;
dispatchEvent(new Event(Event.CHANGE));
}
public function get rotation():Number
{
return _rotation;
}
public function get xVel():Number
{
return _xVel;
}
public function get yVel():Number
{
return _yVel;
}
public function set yVel(value:Number):void
{
_yVel = value;
dispatchEvent(new Event(Event.CHANGE));
}
public function set xVel(value:Number):void
{
_xVel = value;
dispatchEvent(new Event(Event.CHANGE));
}
//public function get angle():Number
// {
// _angle = _rotation * (Math.PI / 180);
// return _angle
// }
}
}