41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
|
import java.awt.*;
|
||
|
|
||
|
public class DrawningBlocks {
|
||
|
private DirectionBlocksOnDeck blocksCount;
|
||
|
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 void Init(int blocksCount, Color color)
|
||
|
{
|
||
|
SetNewBlocks(blocksCount);
|
||
|
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 + 26, y + 10, 10, 5);
|
||
|
g.fillRect(x + 38, y + 10, 10, 5);
|
||
|
g.fillRect(x + 38, y + 35, 10, 5);
|
||
|
g.fillRect(x + 26, y + 35, 10, 5);
|
||
|
}
|
||
|
case Six -> {
|
||
|
g.fillRect(x + 14, y + 10, 10, 5);
|
||
|
g.fillRect(x + 26, y + 10, 10, 5);
|
||
|
g.fillRect(x + 38, y + 10, 10, 5);
|
||
|
g.fillRect(x + 38, y + 35, 10, 5);
|
||
|
g.fillRect(x + 26, y + 35, 10, 5);
|
||
|
g.fillRect(x + 14, y + 35, 10, 5);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|