Pibd-23_Zhelovanov_D.Y._Bat.../DrawningTriangleBlocks.java
2022-12-15 23:04:08 +03:00

55 lines
1.9 KiB
Java

import java.awt.*;
public class DrawningTriangleBlocks implements IDrawningBlocks {
private DirectionBlocksOnDeck blocksOnDeck = DirectionBlocksOnDeck.Two;
@Override
public void DrawBlocks(Graphics g, int x, int y, Color bodyColor) {
g.setColor(Color.black);
switch(blocksOnDeck){
case Four -> {
g.fillPolygon(new int[]{x + 46, x + 54, x+ 60 }, new int[]{y + 7, y, y + 7}, 3);
g.fillPolygon(new int[]{x + 46, x + 54, x+ 60 }, new int[]{y + 49, y + 42, y + 49}, 3);
g.fillPolygon(new int[]{x + 58, x + 66, x+ 72}, new int[]{y + 7, y, y + 7}, 3);
g.fillPolygon(new int[]{x + 58, x + 66, x+72}, new int[]{y + 49, y + 42, y + 49}, 3);
}
case Six -> {
g.fillPolygon(new int[]{x + 46, x + 54, x+ 60 }, new int[]{y + 7, y, y + 7}, 3);
g.fillPolygon(new int[]{x + 66, x + 64, x+ 80 }, new int[]{y + 7, y, y + 7}, 3);
g.fillPolygon(new int[]{x + 46, x + 54, x+ 60 }, new int[]{y + 49, y + 42, y + 49}, 3);
g.fillPolygon(new int[]{x + 66, x + 64, x+ 80 }, new int[]{y + 49, y + 42, y + 49}, 3);
g.fillPolygon(new int[]{x + 58, x + 66, x+ 72}, new int[]{y + 7, y, y + 7}, 3);
g.fillPolygon(new int[]{x + 58, x + 66, x+72}, new int[]{y + 49, y + 42, y + 49}, 3);
}}
}
@Override
public void SetBlocks(int count) {
switch(count)
{
case 2:
blocksOnDeck = DirectionBlocksOnDeck.Two;
break;
case 4:
blocksOnDeck = DirectionBlocksOnDeck.Four;
break;
case 6:
blocksOnDeck = DirectionBlocksOnDeck.Six;
break;
default:
break;
}
}
public DrawningTriangleBlocks (int num) {
SetBlocks(num);
}
}