Add board bg
This commit is contained in:
parent
cf931bc928
commit
919746e58e
5 changed files with 41 additions and 14 deletions
|
@ -34,7 +34,7 @@ public class MainWindowController implements IObserver {
|
|||
|
||||
private int squareSize=100;
|
||||
private int squarePadding=10;
|
||||
private int[] boardPosition={40,0};
|
||||
private int[] boardPosition={30,0};
|
||||
private int fontSize=60;
|
||||
|
||||
|
||||
|
@ -108,10 +108,14 @@ public class MainWindowController implements IObserver {
|
|||
else{
|
||||
this.score.setText("Score : " + this.model.getScore());
|
||||
}
|
||||
int[][] board=this.model.getBoard();
|
||||
|
||||
GraphicsContext gc = boardCanvas.getGraphicsContext2D();
|
||||
gc.clearRect(0,0,500,500);
|
||||
int[][] board=this.model.getBoard();
|
||||
|
||||
gc.setFill(Color.rgb(187,173,160));
|
||||
gc.fillRect(this.boardPosition[0],this.boardPosition[1], ((this.squareSize+squarePadding)*board.length)+squarePadding, ((this.squareSize+squarePadding)*board[0].length)+squarePadding);
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -162,14 +166,11 @@ public class MainWindowController implements IObserver {
|
|||
|
||||
|
||||
int x=this.boardPosition[0] + (j*this.squareSize);
|
||||
int y=this.boardPosition[1] + (i*this.squareSize);
|
||||
x+=(j+1)*squarePadding;
|
||||
|
||||
int y=this.boardPosition[1] + (i*this.squareSize);
|
||||
y+=(i+1)*squarePadding;
|
||||
|
||||
if(j>0){
|
||||
x+=j*squarePadding;
|
||||
}
|
||||
if(i>0){
|
||||
y+=i*squarePadding;
|
||||
}
|
||||
|
||||
gc.fillRect(x,y, this.squareSize, this.squareSize);
|
||||
|
||||
|
@ -194,7 +195,7 @@ public class MainWindowController implements IObserver {
|
|||
}
|
||||
|
||||
gc.setFont(new Font(localFontSize));
|
||||
gc.fillText(strValue, x + (this.squareSize / 2) - ((localFontSize/3)+strValue.length()*localFontSize/5) , y + (this.squareSize / 2) + (localFontSize /3));
|
||||
gc.fillText(strValue, x + (this.squareSize / 2) - ((localFontSize/4)+strValue.length()*localFontSize/5) , y + (this.squareSize / 2) + (localFontSize /3));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue