Compare commits
2 Commits
698025bc8e
...
9648850f1d
Author | SHA1 | Date | |
---|---|---|---|
9648850f1d | |||
7a5f91114c |
47
.gitignore
vendored
47
.gitignore
vendored
@ -1,26 +1,29 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
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" project-jdk-name="19" 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/PIbd_23_Kislitsa_E.D_AirFighter_Hard.iml" filepath="$PROJECT_DIR$/.idea/PIbd_23_Kislitsa_E.D_AirFighter_Hard.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</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>
|
@ -1,2 +1,2 @@
|
||||
# PIbd_23_Kislitsa_E.D_AirFighter_Hard
|
||||
# PIbd-13-Salin-O.A.-Monorail-Hard
|
||||
|
||||
|
9
src/AirFighterHard/DirectionType.java
Normal file
9
src/AirFighterHard/DirectionType.java
Normal file
@ -0,0 +1,9 @@
|
||||
package AirFighterHard;
|
||||
|
||||
public enum DirectionType {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
|
||||
}
|
195
src/AirFighterHard/DrawningAirFighter.java
Normal file
195
src/AirFighterHard/DrawningAirFighter.java
Normal file
@ -0,0 +1,195 @@
|
||||
package AirFighterHard;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawningAirFighter {
|
||||
|
||||
JPanel AirFighterPanel;
|
||||
private EntityAirFighter EntityAirFighter;
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
private int _startPosX = 0;
|
||||
private int _startPosY = 0;
|
||||
private int _airfighterWidth = 160;
|
||||
private int _airfighterHeight = 68;
|
||||
private int _airfighterwingkorpusHeight = 90;
|
||||
private DrawningEngines DrawningEngines;
|
||||
|
||||
public EntityAirFighter EntityAirFighter(){
|
||||
return EntityAirFighter;
|
||||
}
|
||||
public boolean Init(int speed, double weight,Color bodyColor, int engineNumb,
|
||||
int width, int height, boolean racket, boolean wing, JPanel airfighterPanel){
|
||||
if(width <= _airfighterWidth || height <= _airfighterHeight)
|
||||
return false;
|
||||
_startPosY=70;
|
||||
_startPosX = 0;
|
||||
|
||||
airfighterPanel.setSize(width, height);
|
||||
AirFighterPanel = airfighterPanel;
|
||||
airfighterPanel.paint(AirFighterPanel.getGraphics());
|
||||
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityAirFighter = new EntityAirFighter();
|
||||
EntityAirFighter.Init(speed, weight, bodyColor, engineNumb, racket, wing);
|
||||
|
||||
DrawningEngines = new DrawningEngines();
|
||||
DrawningEngines.Init(_airfighterWidth, _airfighterHeight,_startPosX,_startPosY,airfighterPanel);
|
||||
Random rand = new Random();
|
||||
DrawningEngines.ChangeEnginesNumb(rand.nextInt(1, 4));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y){
|
||||
if(EntityAirFighter == null)
|
||||
return;
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
if (x + _airfighterWidth >= _pictureWidth || y + _airfighterHeight >= _pictureHeight) {
|
||||
_startPosX = 0;
|
||||
_startPosY = 70;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTransport(DirectionType direction){
|
||||
if (EntityAirFighter == null)
|
||||
return;
|
||||
AirFighterPanel.paint(AirFighterPanel.getGraphics());
|
||||
switch (direction)
|
||||
{
|
||||
case Left:
|
||||
if (_startPosX - EntityAirFighter.Step() >= 0)
|
||||
_startPosX -= (int) EntityAirFighter.Step();
|
||||
|
||||
break;
|
||||
case Up:
|
||||
if (_startPosY - EntityAirFighter.Step() - _airfighterHeight > 0)
|
||||
_startPosY -= (int) EntityAirFighter.Step();
|
||||
|
||||
break;
|
||||
case Right:
|
||||
if (_startPosX + EntityAirFighter.Step() + _airfighterWidth < _pictureWidth)
|
||||
_startPosX += (int) EntityAirFighter.Step();
|
||||
else
|
||||
_startPosX = _pictureWidth - _airfighterWidth;
|
||||
|
||||
break;
|
||||
case Down:
|
||||
if (_startPosY + EntityAirFighter.Step() + _airfighterwingkorpusHeight < _pictureHeight)
|
||||
_startPosY += (int) EntityAirFighter.Step();
|
||||
|
||||
break;
|
||||
}
|
||||
DrawningEngines.CurX = _startPosX;
|
||||
DrawningEngines.CurY = _startPosY;
|
||||
}
|
||||
|
||||
public void DrawAirFighter(){
|
||||
Graphics2D g2d = (Graphics2D) AirFighterPanel.getGraphics();
|
||||
if (EntityAirFighter == null)
|
||||
return;
|
||||
|
||||
DrawningEngines.DrawEngines();
|
||||
//тело самолёта
|
||||
|
||||
|
||||
|
||||
g2d.setColor(EntityAirFighter.BodyColor());
|
||||
g2d.fillRect(_startPosX + 20,_startPosY +4,140,20);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 20,_startPosY +4,140,20);
|
||||
|
||||
//Нос самолёта
|
||||
int[] xPointsArrNose = {_startPosX + 20,_startPosX + 20,_startPosX-3};
|
||||
int[] yPointsArrNose = {_startPosY + 4,_startPosY + 24,_startPosY + 12};
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillPolygon(xPointsArrNose, yPointsArrNose, xPointsArrNose.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrNose, yPointsArrNose, xPointsArrNose.length);
|
||||
|
||||
// Правое крыло
|
||||
int[] xPointsArrRightWing = {_startPosX + 80,_startPosX+80,_startPosX+85,_startPosX + 100};
|
||||
int[] yPointsArrRightWing = { _startPosY + 4,_startPosY - 66,_startPosY - 66, _startPosY + 4 };
|
||||
g2d.setColor(EntityAirFighter.BodyColor());
|
||||
g2d.fillPolygon(xPointsArrRightWing, yPointsArrRightWing, xPointsArrRightWing.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrRightWing, yPointsArrRightWing, xPointsArrRightWing.length);
|
||||
|
||||
// Левое крыло
|
||||
int[] xPointsArrLeftWing = {_startPosX + 80,_startPosX + 100,_startPosX+85,_startPosX+80};
|
||||
int[] yPointsArrLeftWing = {_startPosY + 24,_startPosY + 24,_startPosY + 94,_startPosY + 94};
|
||||
g2d.setColor(EntityAirFighter.BodyColor());
|
||||
g2d.fillPolygon(xPointsArrLeftWing, yPointsArrLeftWing, xPointsArrLeftWing.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrLeftWing, yPointsArrLeftWing, xPointsArrLeftWing.length);
|
||||
|
||||
// Правое задние крыло
|
||||
int[] xPointsArrRightBackWing={_startPosX + 140,_startPosX + 160,_startPosX+160,_startPosX+140};
|
||||
int[] yPointsArrRightBackWing={ _startPosY + 4,_startPosY + 4,_startPosY - 22,_startPosY -4};
|
||||
g2d.setColor(EntityAirFighter.BodyColor());
|
||||
g2d.fillPolygon(xPointsArrRightBackWing, yPointsArrRightBackWing, xPointsArrRightBackWing.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrRightBackWing, yPointsArrRightBackWing, xPointsArrRightBackWing.length);
|
||||
// Заднее левое крыло
|
||||
int[] xPointsArrLeftBackWing= {_startPosX + 140,_startPosX + 160,_startPosX+160,_startPosX+140};
|
||||
int[] yPointsArrLeftBackWing= {_startPosY + 24,_startPosY + 24,_startPosY + 50,_startPosY + 32};
|
||||
g2d.setColor(EntityAirFighter.BodyColor());
|
||||
g2d.fillPolygon(xPointsArrLeftBackWing, yPointsArrLeftBackWing, xPointsArrLeftBackWing.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrLeftBackWing, yPointsArrLeftBackWing, xPointsArrLeftBackWing.length);
|
||||
//Ракеты
|
||||
if (EntityAirFighter.Racket())
|
||||
{
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(_startPosX + 70, _startPosY - 15, 10, 10);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 70, _startPosY - 15, 10, 10);
|
||||
int[] xPointsArrNoseRacket = {_startPosX + 70,_startPosX + 70,_startPosX + 60};
|
||||
int[] yPointsArrNoseRacket = {_startPosY -5,_startPosY - 15,_startPosY -10};
|
||||
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.fillPolygon(xPointsArrNoseRacket, yPointsArrNoseRacket, xPointsArrNoseRacket.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPointsArrNoseRacket, yPointsArrNoseRacket, xPointsArrNoseRacket.length);
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(_startPosX + 70, _startPosY - 40, 10, 10);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 70, _startPosY - 40, 10, 10);
|
||||
int[] xPoints2ArrNoseRacket = {_startPosX + 70,_startPosX + 70,_startPosX + 60};
|
||||
int[] yPoints2ArrNoseRacket = {_startPosY -30,_startPosY - 40,_startPosY -35};
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.fillPolygon(xPoints2ArrNoseRacket, yPoints2ArrNoseRacket, xPoints2ArrNoseRacket.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPoints2ArrNoseRacket, yPoints2ArrNoseRacket, xPoints2ArrNoseRacket.length);
|
||||
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(_startPosX + 70, _startPosY + 59, 10, 10);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 70, _startPosY + 59, 10, 10);
|
||||
int[] xPoints3ArrNoseRacket ={_startPosX + 70,_startPosX + 70,_startPosX + 60};
|
||||
int[] yPoints3ArrNoseRacket ={_startPosY +59,_startPosY + 69,_startPosY + 64};
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.fillPolygon(xPoints3ArrNoseRacket, yPoints3ArrNoseRacket, xPoints3ArrNoseRacket.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPoints3ArrNoseRacket, yPoints3ArrNoseRacket, xPoints3ArrNoseRacket.length);
|
||||
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(_startPosX + 70, _startPosY + 34, 10, 10);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(_startPosX + 70, _startPosY + 34, 10, 10);
|
||||
int[] xPoints4ArrNoseRacket={_startPosX + 70,_startPosX + 70,_startPosX + 60};
|
||||
int[] yPoints4ArrNoseRacket={_startPosY +34,_startPosY + 44,_startPosY + 39};
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.fillPolygon(xPoints4ArrNoseRacket, yPoints4ArrNoseRacket, xPoints4ArrNoseRacket.length);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawPolygon(xPoints4ArrNoseRacket, yPoints4ArrNoseRacket, xPoints4ArrNoseRacket.length);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
63
src/AirFighterHard/DrawningEngines.java
Normal file
63
src/AirFighterHard/DrawningEngines.java
Normal file
@ -0,0 +1,63 @@
|
||||
package AirFighterHard;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawningEngines {
|
||||
private int WheelSz;
|
||||
JPanel AirFighterPanel;
|
||||
private NumberType EnginesNumb;
|
||||
private Color EngineColor;
|
||||
private int Width, Height;
|
||||
public int CurX, CurY;
|
||||
|
||||
|
||||
boolean Init(int width, int height, int curX, int curY, JPanel airfighterPanel){
|
||||
Width = width;
|
||||
Height = height;
|
||||
CurX = curX;
|
||||
CurY = curY;
|
||||
EngineColor = Color.BLACK;
|
||||
AirFighterPanel = airfighterPanel;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ChangeEnginesNumb(int x){
|
||||
if(x ==1)
|
||||
EnginesNumb = NumberType.Two;
|
||||
if(x == 2)
|
||||
EnginesNumb = NumberType.Four;
|
||||
if(x == 3)
|
||||
EnginesNumb = NumberType.Six;
|
||||
}
|
||||
|
||||
public NumberType WheelsNumb(){
|
||||
return EnginesNumb;
|
||||
}
|
||||
|
||||
public void DrawEngines(){
|
||||
Graphics2D g2d = (Graphics2D) AirFighterPanel.getGraphics();
|
||||
g2d.setColor(EngineColor);
|
||||
g2d.fillOval(CurX + 92,CurY - 15,25,10 );
|
||||
g2d.fillOval(CurX + 92,CurY + 34,25,10 );
|
||||
|
||||
|
||||
|
||||
if (EnginesNumb == NumberType.Four || EnginesNumb == NumberType.Six)
|
||||
{
|
||||
g2d.fillOval(CurX + 86,CurY - 40,25,10 );
|
||||
|
||||
g2d.fillOval(CurX + 86,CurY +59,25,10 );
|
||||
}
|
||||
|
||||
|
||||
if (EnginesNumb == NumberType.Six)
|
||||
{
|
||||
g2d.fillOval(CurX + 128,CurY -7,25,10 );
|
||||
g2d.fillOval(CurX + 128,CurY +25,25,10 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
40
src/AirFighterHard/EntityAirFighter.java
Normal file
40
src/AirFighterHard/EntityAirFighter.java
Normal file
@ -0,0 +1,40 @@
|
||||
package AirFighterHard;
|
||||
import java.awt.*;
|
||||
|
||||
public class EntityAirFighter {
|
||||
private int Speed, EngineNumb;
|
||||
private double Weight, Step;
|
||||
private Color BodyColor;
|
||||
private boolean Wing;
|
||||
private boolean Racket;
|
||||
|
||||
public int Speed(){
|
||||
return Speed;
|
||||
}
|
||||
|
||||
public int WheelNumb(){
|
||||
return EngineNumb;
|
||||
}
|
||||
public double Weight(){
|
||||
return Weight;
|
||||
}
|
||||
public double Step(){
|
||||
return Step;
|
||||
}
|
||||
public Color BodyColor(){
|
||||
return BodyColor;
|
||||
}
|
||||
public boolean Racket(){return Racket;}
|
||||
public boolean Wing(){return Wing;}
|
||||
public void Init(int speed, double weight, Color bodyColor, int engineNumb,
|
||||
boolean racket, boolean wing){
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
Step = (double)Speed * 100 / Weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
EngineNumb = engineNumb;
|
||||
Racket = racket;
|
||||
Wing = wing;
|
||||
}
|
||||
}
|
96
src/AirFighterHard/Main.java
Normal file
96
src/AirFighterHard/Main.java
Normal file
@ -0,0 +1,96 @@
|
||||
package AirFighterHard;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws IOException {
|
||||
JFrame AirFighterFrame = new JFrame();
|
||||
JPanel AirFighterPanel = new JPanel();
|
||||
AirFighterFrame.setLayout(new BorderLayout());
|
||||
AirFighterFrame.setSize(900, 500);
|
||||
AirFighterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
AirFighterFrame.setLayout(new BorderLayout(1,1));
|
||||
DrawningAirFighter DrawningAirFighter = new DrawningAirFighter();
|
||||
AirFighterPanel.setLayout(null);
|
||||
|
||||
BufferedImage RightIcon = ImageIO.read(new File("RightButton.png"));
|
||||
BufferedImage LeftIcon = ImageIO.read(new File("LeftButton.png"));
|
||||
BufferedImage UpIcon = ImageIO.read(new File("UpButton.png"));
|
||||
BufferedImage DownIcon = ImageIO.read(new File("DownButton.png"));
|
||||
|
||||
JButton RightButton = new JButton(new ImageIcon(RightIcon));
|
||||
JButton LeftButton = new JButton(new ImageIcon(LeftIcon));
|
||||
JButton UpButton = new JButton(new ImageIcon(UpIcon));
|
||||
JButton DownButton = new JButton(new ImageIcon(DownIcon));
|
||||
|
||||
JButton CreateButton = new JButton();
|
||||
CreateButton.setText("Создать");
|
||||
CreateButton.setBounds(12, 401, 90, 40);
|
||||
RightButton.setBounds(840,411,30,30);
|
||||
LeftButton.setBounds(768,411,30,30);
|
||||
UpButton.setBounds(804,375,30,30);
|
||||
DownButton.setBounds(804,411,30,30);
|
||||
AirFighterPanel.add(CreateButton);
|
||||
AirFighterPanel.add(RightButton);
|
||||
AirFighterPanel.add(LeftButton);
|
||||
AirFighterPanel.add(UpButton);
|
||||
AirFighterPanel.add(DownButton);
|
||||
AirFighterFrame.add(AirFighterPanel, BorderLayout.CENTER);
|
||||
Random random = new Random();
|
||||
CreateButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
DrawningAirFighter.Init(random.nextInt(100, 300), random.nextDouble(1000, 3000),
|
||||
Color.getHSBColor(random.nextInt(0, 301), random.nextInt(0, 301), random.nextInt(0, 301)),
|
||||
random.nextInt(1, 4),
|
||||
AirFighterPanel.getWidth(), AirFighterPanel.getHeight(), random.nextBoolean(), random.nextBoolean(), AirFighterPanel);
|
||||
DrawningAirFighter.DrawAirFighter();
|
||||
}
|
||||
});
|
||||
RightButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(DrawningAirFighter.EntityAirFighter() == null)
|
||||
return;
|
||||
DrawningAirFighter.MoveTransport(DirectionType.Right);
|
||||
DrawningAirFighter.DrawAirFighter();
|
||||
}
|
||||
});
|
||||
LeftButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(DrawningAirFighter.EntityAirFighter() == null)
|
||||
return;
|
||||
DrawningAirFighter.MoveTransport(DirectionType.Left);
|
||||
DrawningAirFighter.DrawAirFighter();
|
||||
}
|
||||
});
|
||||
UpButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(DrawningAirFighter.EntityAirFighter() == null)
|
||||
return;
|
||||
DrawningAirFighter.MoveTransport(DirectionType.Up);
|
||||
DrawningAirFighter.DrawAirFighter();
|
||||
}
|
||||
});
|
||||
DownButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(DrawningAirFighter.EntityAirFighter() == null)
|
||||
return;
|
||||
DrawningAirFighter.MoveTransport(DirectionType.Down);
|
||||
DrawningAirFighter.DrawAirFighter();
|
||||
}
|
||||
});
|
||||
|
||||
AirFighterFrame.setVisible(true);
|
||||
}
|
||||
}
|
7
src/AirFighterHard/NumberType.java
Normal file
7
src/AirFighterHard/NumberType.java
Normal file
@ -0,0 +1,7 @@
|
||||
package AirFighterHard;
|
||||
|
||||
public enum NumberType {
|
||||
Two,
|
||||
Four,
|
||||
Six
|
||||
}
|
Loading…
Reference in New Issue
Block a user