# Starting first game....i need some hint

hello
my first post here…okay

so im starting to program a small car game…like grand theft auto…
but in the first step im trying to figure out the movement of the car

``````www.billstedt.biz/test/index2.html
``````

but now…i dont know how to add some kind of friction…so that the cars stops after a certain distance and…how can i controll the acceleration?

``````StageWidth = 600;
StageHeight = 400;
arrowMC._x = 550;
arrowMC._y = 350;
porsche_mc.speed = 5;
friction = .5;
_root.attachMovie("arrow_mc", "arrowMC", 50);
porsche_mc.onEnterFrame = moveStuff;
function moveStuff() {
if (Key.isDown(Key.LEFT)) {
porsche_mc._rotation -= 2;
}
if (Key.isDown(Key.RIGHT)) {
porsche_mc._rotation += 2;
}
if (Key.isDown(Key.UP)) {
speed++;
}
if (Key.isDown(Key.DOWN)) {
speed--;
}
rot = Math.PI/180*porsche_mc._rotation;
//trace("Rotation: "+porsche_mc._rotation+"  Bogenmaß: "+rot+"  Sinus: "+Math.sin(rot)+"  Kosinus: "+Math.cos(rot)+"  Tangens:"+Math.tan(rot));
xSpeed = speed*Math.cos(rot);
ySpeed = speed*Math.sin(rot);
porsche_mc._x += xSpeed;
porsche_mc._y += ySpeed;
if (this._x>StageWidth+(this._width/2)) {
this._x = 0-(this._width/2);
}
if (this._x<0-(this._width/2)) {
this._x = StageWidth+(this._width/2);
}
if (this._y>StageHeight+(this._height/2)) {
this._y = 0-(this._height/2);
}
if (this._y<0-(this._height/2)) {
this._y = StageHeight+(this._height/2);
}
}

``````