onClipEvent (load) {
speed = 4;
radius = 8;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
if (!_root.wall.hitTest(_x-speed-radius, _y, true)) {
_x -= speed;
}
}
if (Key.isDown(Key.RIGHT)) {
if (!_root.wall.hitTest(_x+speed+radius, _y, true)) {
_x += speed;
}
}
if (Key.isDown(Key.UP)) {
if (!_root.wall.hitTest(_x, _y-speed-radius, true)) {
_y -= speed;
}
}
if (Key.isDown(Key.DOWN)) {
if (!_root.wall.hitTest(_x, _y+speed+radius, true)) {
_y += speed;
}
}
}It goes in the player and ALL the walls are given the instance 'wall'.