if (Key.isDown(Key.RIGHT)) {
_root.hero._rotation = 0;
CMove(hero._x+10, hero._y);
} else if (Key.isDown(Key.LEFT)) {
_root.hero._rotation = 180;
CMove(hero._x-10, hero._y);
} else if (Key.isDown(Key.UP)) {
_root.hero._rotation = -90;
CMove(hero._x, hero._y-10);
} else if (Key.isDown(Key.DOWN)) {
_root.hero._rotation = 90;
CMove(hero._x, hero._y+10);
}
};
function CMove(x, y) {
var heroRight = x+20;
var heroLeft = x-20;
var heroUp = y-20;
var heroDown = y+20;
var Move = OK;
if (wall.hitTest(heroRight, heroUP, true)) {
Move = false;
} else if (wall.hitTest(heroRight, heroDown, true)) {
Move = false;
} else if (wall.hitTest(heroLeft, heroUp, true)) {
Move = false;
} else if (wall.hitTest(heroLeft, heroDown, true)) {
Move = false;
} else if (Move == OK) {
hero._x = x;
hero._y = y;
}
}