# Accel and deccel

**URL:** <https://forum.kirupa.com/t/accel-and-deccel/192875>\
**Category:** Uncategorized\
**Created:** [July 2, 2006, 8:44am UTC](https://forum.kirupa.com/t/accel-and-deccel/192875 "2006-07-02T08:44:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mario\_hater](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@mario\_hater](https://forum.kirupa.com/u/mario_hater)\
**Post date:** [July 2, 2006, 8:44am UTC](https://forum.kirupa.com/t/accel-and-deccel/192875/1 "2006-07-02T08:44:06Z")

</div>

i made a code up for acceleration and decelleration or however you spell it.

is this the right code for it because i dont think it is:

onClipEvent (load) {  
left = 0;  
right = 0;  
up = 0;  
down = 0;  
}  
onClipEvent (enterFrame) {  
if (Key.isDown(Key.RIGHT)) {  
right++;  
\_x += right;  
}  
if (!Key.isDown(Key.RIGHT)) {  
if (right\>0) {  
right–;  
\_x += right;  
}  
}  
///////////////////////////  
if (Key.isDown(Key.LEFT)) {  
left–;  
\_x += left;  
}  
if (!Key.isDown(Key.LEFT)) {  
if (left\<0) {  
left++;  
\_x += left;  
}  
}  
///////////////////////////  
if (Key.isDown(Key.UP)) {  
up–;  
\_y += up;  
}  
if (!Key.isDown(Key.UP)) {  
if (up\<0) {  
up++;  
\_y += up;  
}  
}  
///////////////////////////  
if (Key.isDown(Key.DOWN)) {  
down++;  
\_y += down;  
}  
if (!Key.isDown(Key.DOWN)) {  
if (down\>0) {  
down–;  
\_y += down;  
}  
}  
//////////////////////////  
if (\_x\>550) {  
\_x = 0;  
}  
if (\_x\<0) {  
\_x = 550;  
}  
if(\_y\<0){  
\_y=400  
}  
if(\_y\>400){  
\_y=0  
}  
}
