Hey - I’m trying to figure out how to add walls to the movement i’ve coded so far. It moves fine, but any type of wall i set up (using hitTest) doesn’t seem to work. Anyone have any idea? I think it has something to do with the acceleration and deceleration that I coded in. What I want to happen is when the circle (car) runs into a wall, it will slide along the wall, as if it was a real car and it hit a wall and just kept accelerating. I don’t want it to completely stop, just to slide along the wall, and then allow the circle to still turn, or reverse. Any ideas??? thanks - Chris
onClipEvent (load) {
d = 0;
r = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this._rotation -= 5;
}
if (Key.isDown(Key.RIGHT)) {
this._rotation += 5;
}
if (Key.isDown(Key.UP)) {
d += .25;
if (d > 7) {
d = 7;
}
this._x += d*Math.sin((_rotation*Math.PI)/180);
this._y -= d*Math.cos((_rotation*Math.PI)/180);
} else {
d -= .25;
if (d < 0) {
d = 0;
}
this._x += d*Math.sin((_rotation*Math.PI)/180);
this._y -= d*Math.cos((_rotation*Math.PI)/180);
}
if (Key.isDown(Key.DOWN)) {
r += .25;
if (r > 5) {
r = 5;
}
this._x -= r*Math.sin((_rotation*Math.PI)/180);
this._y += r*Math.cos((_rotation*Math.PI)/180);
} else {
r -= .25;
if (r < 0) {
r = 0;
}
this._x -= r*Math.sin((_rotation*Math.PI)/180);
this._y += r*Math.cos((_rotation*Math.PI)/180);
}
if (this._x < -30) {
this._x = 430;
}
if (this._x > 430) {
this._x = -30;
}
if (this._y < -30) {
this._y = 430;
}
if (this._y > 430) {
this._y = -30;
}
}
SWF attached - THANKS