36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
|
import java.awt.*;
|
||
|
|
||
|
public class DrawingDecks {
|
||
|
private DecksCount deckCount;
|
||
|
private Color color;
|
||
|
|
||
|
public void Init(int deckCount, Color bodyColor) {
|
||
|
setdecksCount(deckCount);
|
||
|
color = bodyColor;
|
||
|
}
|
||
|
|
||
|
public void setdecksCount(int num) {
|
||
|
if (num <= 1) {
|
||
|
deckCount = DecksCount.One;
|
||
|
} else if (num >= 3) {
|
||
|
deckCount = DecksCount.Three;
|
||
|
}
|
||
|
else {
|
||
|
deckCount = DecksCount.Two;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void draw(Graphics2D g, int x, int y, int shipWidth, int shipHeight) {
|
||
|
g.setColor(color != null ? color : Color.BLACK);
|
||
|
switch (deckCount) {
|
||
|
case Two: {
|
||
|
g.fillRect(x, y + 5, 15, 5);
|
||
|
g.fillPolygon(new int[] {x, x, x + 5}, new int[] {y + 5, y + 10, y + 10}, 3);
|
||
|
}
|
||
|
case Three: {
|
||
|
g.fillRect(x + shipWidth - 20, y, 20, 10);
|
||
|
g.fillPolygon(new int[] {x + shipWidth - 20, x + shipWidth - 20, x + shipWidth - 25}, new int[] {y, y + 10, y + 10}, 3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|