diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/WarshipHard.iml b/.idea/WarshipHard.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/.idea/WarshipHard.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..082ca23 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Resource/arrowDown.jpg b/Resource/arrowDown.jpg new file mode 100644 index 0000000..4813a5b Binary files /dev/null and b/Resource/arrowDown.jpg differ diff --git a/Resource/arrowLeft.jpg b/Resource/arrowLeft.jpg new file mode 100644 index 0000000..0f9441d Binary files /dev/null and b/Resource/arrowLeft.jpg differ diff --git a/Resource/arrowRight.jpg b/Resource/arrowRight.jpg new file mode 100644 index 0000000..cea4be5 Binary files /dev/null and b/Resource/arrowRight.jpg differ diff --git a/Resource/arrowUp.jpg b/Resource/arrowUp.jpg new file mode 100644 index 0000000..80d3aa0 Binary files /dev/null and b/Resource/arrowUp.jpg differ diff --git a/src/BlockCount.java b/src/BlockCount.java new file mode 100644 index 0000000..b49dbfe --- /dev/null +++ b/src/BlockCount.java @@ -0,0 +1,13 @@ +public enum BlockCount { + TwoBlocks(2), + FourBlocks(4), + SixBlocks(6); + + private final int value; + BlockCount(int count){ + value=count; + } + public int GetBlockCount(){ + return value; + } +} diff --git a/src/DrawingBlock.java b/src/DrawingBlock.java new file mode 100644 index 0000000..0189e61 --- /dev/null +++ b/src/DrawingBlock.java @@ -0,0 +1,47 @@ +import java.awt.*; + +public class DrawingBlock { + + private BlockCount _Block; + + public void SetBlockCount(int count){ + for (BlockCount temp: BlockCount.values()) + if (temp.GetBlockCount() == count){ + _Block=temp; + return; + } + } + + public void DrawBlock(Graphics2D g,int _startPosX, int _startPosY) { + if (_Block.GetBlockCount() >= 2) { + g.setColor(Color.GRAY); + g.fillRect(_startPosX + 25, _startPosY + 10, 10, 10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 25, _startPosY + 10, 10, 10); + g.setColor(Color.GRAY); + g.fillRect(_startPosX + 25, _startPosY + 20, 10, 10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 25, _startPosY + 20, 10, 10); + } + if (_Block.GetBlockCount() >= 4) { + g.setColor(Color.GRAY); + g.fillRect(_startPosX+35,_startPosY+10,10,10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX+35,_startPosY+10,10,10); + g.setColor(Color.GRAY); + g.fillRect(_startPosX+35,_startPosY+20,10,10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX+35,_startPosY+20,10,10); + } + if (_Block.GetBlockCount() >= 6) { + g.setColor(Color.GRAY); + g.fillRect(_startPosX+45,_startPosY+10,10,10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX+45,_startPosY+10,10,10); + g.setColor(Color.GRAY); + g.fillRect(_startPosX+45,_startPosY+20,10,10); + g.setColor(Color.BLACK); + g.drawRect(_startPosX+45,_startPosY+20,10,10); + } + } +} diff --git a/src/DrawingWarship.java b/src/DrawingWarship.java index 9c929f0..440d8ad 100644 --- a/src/DrawingWarship.java +++ b/src/DrawingWarship.java @@ -5,6 +5,7 @@ public class DrawingWarship { public EntityWarship GetWarship(){ return Warship; } + public DrawingBlock Blocks; private int _startPosX; private int _startPosY; private Integer _pictureWidth = null; @@ -16,6 +17,8 @@ public class DrawingWarship { { Warship = new EntityWarship(); Warship.Init(speed, weight, bodyColor); + Blocks= new DrawingBlock(); + Blocks.SetBlockCount(2*(int)(Math.random()*3+1)); } public void SetPosition(int x, int y, int width, int height) @@ -95,17 +98,12 @@ public class DrawingWarship { g2.fillRect(_startPosX, _startPosY + 5, 5, 10); g2.fillRect(_startPosX, _startPosY + 25, 5, 10); - g2.setColor(Color.DARK_GRAY); - - g2.drawRect(_startPosX + 30, _startPosY + 15, 20, 10); - g2.fillRect(_startPosX+30, _startPosY + 15, 20, 10); - g2.drawRect(_startPosX + 50, _startPosY + 10, 10, 20); - g2.fillRect(_startPosX + 50, _startPosY + 10, 10, 20); - g2.setColor(Color.BLUE); g2.drawOval(_startPosX + 70, _startPosY + 15, 10, 10); g2.fillOval(_startPosX + 70, _startPosY + 15, 10, 10); + + Blocks.DrawBlock(g2, _startPosX,_startPosY); } public void ChangeBorders(int width,int height)