76 lines
2.4 KiB
Java
76 lines
2.4 KiB
Java
import java.awt.*;
|
|
|
|
public class DrawningBlocks implements IDrawningBlocks {
|
|
private DirectionBlocksOnDeck blocksCount = DirectionBlocksOnDeck.Two;
|
|
private Color color;
|
|
public void SetNewBlocks(int countBlocks){
|
|
if (countBlocks == 4) {
|
|
blocksCount = DirectionBlocksOnDeck.Four;
|
|
} else if (countBlocks == 6) {
|
|
blocksCount = DirectionBlocksOnDeck.Six;
|
|
}
|
|
else {
|
|
blocksCount = DirectionBlocksOnDeck.Two;
|
|
}
|
|
}
|
|
public DrawningBlocks(int count, Color color){
|
|
SetBlocks(count);
|
|
this.color = color;
|
|
}
|
|
public void Draw(Graphics2D g, int x, int y) {
|
|
g.setColor(color != null ? color : Color.BLACK);
|
|
switch (blocksCount) {
|
|
case Four -> {
|
|
g.fillRect(x + 36, y + 5, 10, 5);
|
|
g.fillRect(x + 48, y + 5, 10, 5);
|
|
g.fillRect(x + 38, y + 40, 10, 5);
|
|
g.fillRect(x + 46, y + 40, 10, 5);
|
|
}
|
|
case Six -> {
|
|
g.fillRect(x + 14, y + 5, 10, 5);
|
|
g.fillRect(x + 26, y + 5, 10, 5);
|
|
g.fillRect(x + 38, y + 5, 10, 5);
|
|
g.fillRect(x + 38, y + 40, 10, 5);
|
|
g.fillRect(x + 26, y + 40, 10, 5);
|
|
g.fillRect(x + 14, y + 40, 10, 5);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void DrawBlocks(Graphics g, int x, int y, Color bodyColor) {
|
|
g.setColor(color != null ? color : Color.BLACK);
|
|
switch (blocksCount) {
|
|
case Four -> {
|
|
g.fillRect(x + 58, y, 8, 5);
|
|
g.fillRect(x + 70, y, 8, 5);
|
|
g.fillRect(x + 70, y + 40, 8, 5);
|
|
g.fillRect(x + 58, y + 40, 8, 5);
|
|
}
|
|
case Six -> {
|
|
g.fillRect(x + 46, y, 8, 5);
|
|
g.fillRect(x + 58, y , 8, 5);
|
|
g.fillRect(x + 70, y, 8, 5);
|
|
g.fillRect(x + 46, y + 45, 8, 5);
|
|
g.fillRect(x + 58, y + 45, 8, 5);
|
|
g.fillRect(x + 70, y + 45, 8, 5);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void SetBlocks(int count) {
|
|
switch(count)
|
|
{
|
|
case 4:
|
|
blocksCount = DirectionBlocksOnDeck.Four;
|
|
break;
|
|
case 6:
|
|
blocksCount = DirectionBlocksOnDeck.Six;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|