1
0
Fork 0

Turn ship to face the target when firing

This commit is contained in:
Michaël Lemaire 2015-02-23 01:00:00 +01:00
parent 8cf4e31d95
commit 93cf052f5e

View file

@ -111,6 +111,12 @@ module SpaceTac.View {
var source = this.view.arena.findShipSprite(event.ship);
var destination = this.view.arena.findShipSprite(event.target.ship);
var dy = destination.y - source.y;
var dx = destination.x - source.x;
var angle = Math.atan2(dy, dx);
source.moveTo(source.x, source.y, angle, true);
var effect = new WeaponEffect(source, destination, event.weapon.code);
effect.start();
}