Adding Color to pieces (#31)
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			Just adding a color field to pieces for drawing later Carefull when you review, I also moved Vec2 to Utils where I feel it belong. Solve #29 Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com> Reviewed-on: #31 Reviewed-by: Mat_02 <diletomatteo@gmail.com>
This commit is contained in:
		@ -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 transient Paint color; // https://www.baeldung.com/java-transient-keyword
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user