Adding Color
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Debucquoy Anthony 2023-05-01 19:41:39 +02:00
parent c6df656381
commit d561433968
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,10 @@
package school_project;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import java.util.Random;
/**
* Represent a Piece in the game.
* Every Piece should be contained in a Map Object.
@ -10,13 +15,20 @@ public class Piece extends Shape{
private Vec2 Position;
private Map linked_map;
public Piece() {
super();
}
private Paint color;
public Piece(boolean[][] matrix) {
super(matrix);
Random rand = new Random();
color = new Color(rand.nextDouble(), rand.nextDouble(), rand.nextDouble(), 1);
}
public void setColor(Paint p){
color = p;
}
public Paint getColor(){
return color;
}
public Vec2 getPosition() {
@ -27,6 +39,7 @@ public class Piece extends Shape{
this.Position = position;
}
/**
* set the map the piece is into the the map argument
* @param map map where to place the piece

View File

@ -36,7 +36,7 @@ class PieceTest {
{true, false, true},
};
Piece piece1 = new Piece();
Piece piece1 = new Piece(piece2_matrix);
piece1.setShape(piece1_matrix);
Piece piece2 = new Piece(piece2_matrix);