I’m creating a game with two ships that fly around trying to shoot one another. It is two player with one ship using One ship uses the arrow keys to fly, that one works. The other, which uses the “A”, “W”, “S”, and “D” does not work.
Here is the code for the ship that uses the arrow keys:
ship2.onEnterFrame = function() {
Key.isDown(Key.UP) ? (this.speed = +7.5) : Key.isDown(Key.DOWN) ? (this.speed = -3.75) : null;
Key.isDown(Key.LEFT) ? this._rotation -= 12.5 : Key.isDown(Key.RIGHT) ? this._rotation += 12.5 : null;
this._x<=0 ? this._x=1100 : this._x>=1100 ? this._x=0 : null;
this._y<=0 ? this._y=800 : this._y>=800 ? this._y=0 : null;
this.speed = .94, this.roto=this._rotation(Math.PI/180);
this._x += Math.sin(this.roto)*this.speed;
this._y -= Math.cos(this.roto)*this.speed;
updateAfterEvent();
};
This is the code for the A,S,W,D ship:
ship1.onEnterFrame = function() {
Key.isDown(Key.119) ? (this.speed = +12.5) : Key.isDown(Key.115) ? (this.speed = -6.25) : null;
Key.isDown(Key.97) ? this._rotation -= 7.5 : Key.isDown(Key.100) ? this._rotation += 7.5 : null;
this._x<=0 ? this._x=1100 : this._x>=1100 ? this._x=0 : null;
this._y<=0 ? this._y=800 : this._y>=800 ? this._y=0 : null;
this.speed = .94, this.roto=this._rotation(Math.PI/180);
this._x += Math.sin(this.roto)*this.speed;
this._y -= Math.cos(this.roto)*this.speed;
updateAfterEvent();
};
I believe the numbers are the correct ascii numbers, but I am unsure. Any help you could offer will be greatly appreciated.
Thank you!