Первая лабораторная работа. Усложненная. С дополнительным заданием.
This commit is contained in:
parent
bad7c423b4
commit
143fc0e022
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
11
.idea/WarshipHard.iml
Normal file
11
.idea/WarshipHard.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/WarshipHard.iml" filepath="$PROJECT_DIR$/.idea/WarshipHard.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
BIN
Resource/arrowDown.jpg
Normal file
BIN
Resource/arrowDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
Resource/arrowLeft.jpg
Normal file
BIN
Resource/arrowLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
Resource/arrowRight.jpg
Normal file
BIN
Resource/arrowRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
Resource/arrowUp.jpg
Normal file
BIN
Resource/arrowUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
13
src/BlockCount.java
Normal file
13
src/BlockCount.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
47
src/DrawingBlock.java
Normal file
47
src/DrawingBlock.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user