Pibd-23_Zhelovanov_D.Y._Bat.../DrawningBlocks.java

46 lines
1.3 KiB
Java
Raw Normal View History

import java.awt.*;
2022-12-06 17:23:28 +04:00
public class DrawningBlocks implements IDrawningBlocks {
private DirectionBlocksOnDeck blocksCount = DirectionBlocksOnDeck.Two;
private Color color;
2022-12-06 17:23:28 +04:00
public DrawningBlocks(int count, Color color){
SetBlocks(count);
this.color = color;
2022-12-06 17:23:28 +04:00
}
@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;
}
}
}