Skip to content
Snippets Groups Projects
Commit 812da24b authored by Memo Akten's avatar Memo Akten
Browse files

player ships are drawn different colors (green and blue)

parent 6ebca243
No related branches found
No related tags found
No related merge requests found
......@@ -40,14 +40,18 @@ public class NeuroShip extends GameObject {
// position and velocity
public Vector2d d;
// played id (used for drawing)
int playerID;
public NeuroShip(Vector2d s, Vector2d v, Vector2d d) {
public NeuroShip(Vector2d s, Vector2d v, Vector2d d, int playerID) {
super(new Vector2d(s), new Vector2d(v));
this.d = new Vector2d(d);
this.playerID = playerID;
}
public NeuroShip copy() {
NeuroShip ship = new NeuroShip(s, v, d);
NeuroShip ship = new NeuroShip(s, v, d, playerID);
ship.releaseVelocity = releaseVelocity;
return ship;
}
......@@ -137,6 +141,7 @@ public class NeuroShip extends GameObject {
}
public void draw(Graphics2D g) {
color = playerID == 0 ? Color.green : Color.blue;
AffineTransform at = g.getTransform();
g.translate(s.x, s.y);
double rot = Math.atan2(d.y, d.x) + Math.PI / 2;
......
......@@ -68,17 +68,17 @@ public class SimpleBattle {
protected void reset() {
stats.clear();
objects.clear();
s1 = buildShip(250, 250);
s2 = buildShip(300, 300);
s1 = buildShip(250, 250, 0);
s2 = buildShip(300, 300, 1);
this.currentTick = 0;
}
protected NeuroShip buildShip(int x, int y) {
protected NeuroShip buildShip(int x, int y, int playerID) {
Vector2d position = new Vector2d(x, y);
Vector2d speed = new Vector2d();
Vector2d direction = new Vector2d(1, 0);
return new NeuroShip(position, speed, direction );
return new NeuroShip(position, speed, direction, playerID );
}
public void update() {
......
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