dark acalyte
11-22-2007, 03:33 AM
The game I am making is a side scroller so basically rightKeyPress is going forward, leftKeyPress goes back upKeyPress goes up, etc.etc.
the problem I'm having is that I can move diagonally in any direction, and i can move diagonally in any direction + shoot except for when im press up + left, going in the north west direction, i can shoot or move in that direction but not both, im not sure what the problem is but i can move+ shoot in any other direction, the movement + shoot code is down below so if anyone can figure it out thanks in advance.
this.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
if (ghost.hitTest(ghost._x-40, 0, true)) {
ghost._y += 8;
}
ghost._y -= 8;
}
if (Key.isDown(Key.LEFT)) {
if (ghost.hitTest(0, ghost._y, true)) {
ghost._x += 7.5;
}
ghost._x -= 7.5;
}
if (Key.isDown(Key.DOWN)) {
if (ghost.hitTest(ghost._x-40, 400, true)) {
ghost._y -= 8;
}
ghost._y += 8;
}
if (Key.isDown(Key.RIGHT)) {
if (ghost.hitTest(345, ghost._y, true)) {
ghost._x -= 8.6;
}
ghost._x += 9;
}
timer++;
if (Key.isDown(Key.SPACE)) {
i++;
if (timer>=4) {
_root.attachMovie("Particle", "Particle"+i, _root.getNextHighestDepth());
_root["Particle"+i]._x = ghost._x+12;
_root["Particle"+i]._y = ghost._y;
timer = 0;
}
}
}
the problem I'm having is that I can move diagonally in any direction, and i can move diagonally in any direction + shoot except for when im press up + left, going in the north west direction, i can shoot or move in that direction but not both, im not sure what the problem is but i can move+ shoot in any other direction, the movement + shoot code is down below so if anyone can figure it out thanks in advance.
this.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
if (ghost.hitTest(ghost._x-40, 0, true)) {
ghost._y += 8;
}
ghost._y -= 8;
}
if (Key.isDown(Key.LEFT)) {
if (ghost.hitTest(0, ghost._y, true)) {
ghost._x += 7.5;
}
ghost._x -= 7.5;
}
if (Key.isDown(Key.DOWN)) {
if (ghost.hitTest(ghost._x-40, 400, true)) {
ghost._y -= 8;
}
ghost._y += 8;
}
if (Key.isDown(Key.RIGHT)) {
if (ghost.hitTest(345, ghost._y, true)) {
ghost._x -= 8.6;
}
ghost._x += 9;
}
timer++;
if (Key.isDown(Key.SPACE)) {
i++;
if (timer>=4) {
_root.attachMovie("Particle", "Particle"+i, _root.getNextHighestDepth());
_root["Particle"+i]._x = ghost._x+12;
_root["Particle"+i]._y = ghost._y;
timer = 0;
}
}
}