ok, I’m making a top-down shooter game. I have keyboard input that moves the ship around and fires a laser. everything works perfect except that when the ship moves diagonal up left, or diagonal down right, the laser can’t fire at the same time. It will work in any other direction, including the other diagonals. Just not those two : (
here is my code:
[AS]
function captureKeys() {
if (Key.isDown(Key.RIGHT) && ship.x < 355 ) {
ship.x+=ship.right
} else if (Key.isDown(Key.LEFT) && ship.x > 50) {
ship.x+=ship.left
}
if (Key.isDown(Key.UP) && ship.y > 22) {
ship.y+=ship.up
} else if (Key.isDown(Key.DOWN) && ship.y < 500) {
ship.y+=ship.down
}
if (Key.isDown(Key.SPACE) && okToShoot) {
okToShoot = false;
var newDepth = ++depth;
var name = "projectile"+newDepth;
var linkage = "laser"+ship.laser;
var clip = _root.attachMovie(linkage, name, newDepth);
clip._x = ship.x;
clip._y = (ship.y -20)
clip.ymov = -25
clip.onEnterFrame = function() {
this._y += this.ymov;
if (this._y < 0) this.removeMovieClip();
};
} else if (!Key.isDown(Key.SPACE)){
okToShoot=true
}
}
[/AS]
is this a common problem among movement in games? or do I just need to fix something?