Add a condition to avoid white piece
This commit is contained in:
		@ -6,6 +6,8 @@ import javafx.scene.paint.Paint;
 | 
				
			|||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Random;
 | 
					import java.util.Random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static javafx.scene.paint.Color.color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represent a Piece in the game.
 | 
					 * Represent a Piece in the game.
 | 
				
			||||||
 * Every Piece should be contained in a Map Object.
 | 
					 * Every Piece should be contained in a Map Object.
 | 
				
			||||||
@ -22,6 +24,9 @@ public class Piece extends Shape{
 | 
				
			|||||||
        super(matrix);
 | 
					        super(matrix);
 | 
				
			||||||
        Random rand = new Random();
 | 
					        Random rand = new Random();
 | 
				
			||||||
        color = new Color(rand.nextDouble(), rand.nextDouble(), rand.nextDouble(), 1);
 | 
					        color = new Color(rand.nextDouble(), rand.nextDouble(), rand.nextDouble(), 1);
 | 
				
			||||||
 | 
					        while(color.equals(color(255, 255, 255))) {
 | 
				
			||||||
 | 
					            color = new Color(rand.nextDouble(), rand.nextDouble(), rand.nextDouble(), 1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setColor(Paint p){
 | 
					    public void setColor(Paint p){
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user