1
0
Fork 0

Adjusted initial ship placement to work with a fleet of 5 ships

This commit is contained in:
Michaël Lemaire 2015-04-22 22:18:49 +02:00
parent 477b51bd9f
commit b60cd52510
2 changed files with 7 additions and 7 deletions

View file

@ -91,8 +91,8 @@ module SpaceTac.Game {
// Defines the initial ship positions of all engaged fleets
placeShips(): void {
this.first_turn = true;
this.placeFleetShips(this.fleets[0], 50, 300, 0);
this.placeFleetShips(this.fleets[1], 800, 300, Math.PI);
this.placeFleetShips(this.fleets[0], 50, 310, 0);
this.placeFleetShips(this.fleets[1], 800, 310, Math.PI);
}
// Count the number of fleets still alive
@ -244,7 +244,7 @@ module SpaceTac.Game {
// facing_angle is the forward angle in radians
private placeFleetShips(fleet: Fleet, x: number, y: number, facing_angle: number): void {
var side_angle = facing_angle + Math.PI * 0.5;
var spacing = 150;
var spacing = 140;
var total_length = spacing * (fleet.ships.length - 1);
var dx = Math.cos(side_angle);
var dy = Math.sin(side_angle);

View file

@ -43,11 +43,11 @@ module SpaceTac.Game {
battle.placeShips();
expect(ship1.arena_x).toBeCloseTo(50, 0.0001);
expect(ship1.arena_y).toBeCloseTo(150, 0.0001);
expect(ship1.arena_y).toBeCloseTo(170, 0.0001);
expect(ship1.arena_angle).toBeCloseTo(0, 0.0001);
expect(ship2.arena_x).toBeCloseTo(50, 0.0001);
expect(ship2.arena_y).toBeCloseTo(300, 0.0001);
expect(ship2.arena_y).toBeCloseTo(310, 0.0001);
expect(ship2.arena_angle).toBeCloseTo(0, 0.0001);
expect(ship3.arena_x).toBeCloseTo(50, 0.0001);
@ -55,11 +55,11 @@ module SpaceTac.Game {
expect(ship3.arena_angle).toBeCloseTo(0, 0.0001);
expect(ship4.arena_x).toBeCloseTo(800, 0.0001);
expect(ship4.arena_y).toBeCloseTo(375, 0.0001);
expect(ship4.arena_y).toBeCloseTo(380, 0.0001);
expect(ship4.arena_angle).toBeCloseTo(Math.PI, 0.0001);
expect(ship5.arena_x).toBeCloseTo(800, 0.0001);
expect(ship5.arena_y).toBeCloseTo(225, 0.0001);
expect(ship5.arena_y).toBeCloseTo(240, 0.0001);
expect(ship5.arena_angle).toBeCloseTo(Math.PI, 0.0001);
});