Skip to content
Snippets Groups Projects
Commit dd8fec44 authored by Piers Williams's avatar Piers Williams
Browse files

Merge remote-tracking branch 'origin/master' into piers

parents 9cc651ed cd2c1b88
No related branches found
No related tags found
No related merge requests found
...@@ -13,12 +13,24 @@ public class Action { ...@@ -13,12 +13,24 @@ public class Action {
public Action() {} public Action() {}
/**
* Create a new action to be executed by the controller
*
* @param thrust 1 is full thrust, 0 is nothing
* @param turn 1 is clockwise, -1 is anticlockwise, 0 is don't turn
* @param shoot true is fire, false is don't fire
*/
public Action(double thrust, double turn, boolean shoot) { public Action(double thrust, double turn, boolean shoot) {
this.thrust = thrust; this.thrust = thrust;
this.turn = turn; this.turn = turn;
this.shoot = shoot; this.shoot = shoot;
} }
/**
* Create an action which is a copy of an existing action
*
* @param a the action to clone
*/
public Action(Action a) { public Action(Action a) {
thrust = a.thrust; thrust = a.thrust;
turn = a.turn; turn = a.turn;
......
...@@ -86,7 +86,6 @@ public class SimpleBattle { ...@@ -86,7 +86,6 @@ public class SimpleBattle {
// apply them to each player's ship, taking actions as necessary // apply them to each player's ship, taking actions as necessary
Action a1 = p1.getAction(this, 0); Action a1 = p1.getAction(this, 0);
Action a2 = p2.getAction(this, 1); Action a2 = p2.getAction(this, 1);
update(a1, a2); update(a1, a2);
} }
...@@ -148,7 +147,7 @@ public class SimpleBattle { ...@@ -148,7 +147,7 @@ public class SimpleBattle {
return statsClone; return statsClone;
} }
public void checkCollision(GameObject actor) { protected void checkCollision(GameObject actor) {
// check with all other game objects // check with all other game objects
// but use a hack to only consider interesting interactions // but use a hack to only consider interesting interactions
// e.g. asteroids do not collide with themselves // e.g. asteroids do not collide with themselves
...@@ -189,7 +188,7 @@ public class SimpleBattle { ...@@ -189,7 +188,7 @@ public class SimpleBattle {
} }
} }
public void fireMissile(Vector2d s, Vector2d d, int playerId) { protected void fireMissile(Vector2d s, Vector2d d, int playerId) {
// need all the usual missile firing code here // need all the usual missile firing code here
NeuroShip currentShip = playerId == 0 ? s1 : s2; NeuroShip currentShip = playerId == 0 ? s1 : s2;
PlayerStats stats = this.stats.get(playerId); PlayerStats stats = this.stats.get(playerId);
...@@ -222,9 +221,27 @@ public class SimpleBattle { ...@@ -222,9 +221,27 @@ public class SimpleBattle {
s2.draw(g); s2.draw(g);
} }
public NeuroShip getShip(int playerID) {
assert playerID < 2;
assert playerID >= 0;
if (playerID == 0) {
return s1.copy();
} else {
return s2.copy();
}
}
public ArrayList<GameObject> getObjects() public ArrayList<GameObject> getObjects()
{ {
return objects; return new ArrayList<>(objects);
}
public PlayerStats getStats(int playerID) {
assert playerID < 2;
assert playerID >= 0;
return stats.get(playerID);
} }
static class PlayerStats { static class PlayerStats {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment