Доработка

This commit is contained in:
Володя 2022-12-04 00:29:17 +03:00
parent 566571ab19
commit f97e47e9d1
6 changed files with 22 additions and 12 deletions

View File

@ -2,14 +2,14 @@ import javax.swing.*;
import java.awt.*;
public class Canvas extends JComponent {
FormAirPlane form;
public Canvas(FormAirPlane form) {
Form form;
public Canvas(Form form) {
this.form = form;
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
form.draw(g2);
form.Draw(g2);
}
}

View File

@ -11,7 +11,7 @@ class DrawingEntityPlain
private int _pictureHeight = -1;
private int _AirplaneWidth = 240;
private int _AirplaneHeight = 120;
private int _AirplaneHeight = 150;
public void Init(int speed, float weight, Color bodyColor)
{

View File

@ -3,17 +3,20 @@ import java.awt.*;
public class DrawingPorthole {
private Porthole PortholeCount;
Color color;
public void Init(int count, Color bodyColor) {
public void SetCount(int count){
if(count <= 10) PortholeCount = Porthole.Ten;
else if(count >= 30) PortholeCount = Porthole.Twenty;
else PortholeCount = Porthole.Thirty;
}
public void Init(int count, Color bodyColor) {
SetCount(count);
color = bodyColor;
}
public void draw(Graphics2D g, int startPosX, int startPosY) {
g.setPaint(Color.white);
int count = 0;
@ -21,7 +24,7 @@ public class DrawingPorthole {
int j = 0;
while(true)
{
if(i==15) {
if(i==14) {
i = 0;
j=30;
}

View File

@ -0,0 +1,5 @@
import java.awt.*;
public interface Form {
void Draw(Graphics2D g);
}

View File

@ -57,7 +57,9 @@
<constraints>
<grid row="1" column="0" row-span="1" col-span="7" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<properties>
<background color="-5833743"/>
</properties>
<border type="none"/>
<children>
<hspacer id="eb27d">

View File

@ -5,7 +5,7 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.Random;
public class FormAirPlane {
public class FormAirPlane implements Form {
private JButton createButton;
private JButton upButton;
private JButton rightButton;
@ -87,8 +87,8 @@ public class FormAirPlane {
canv.repaint();
});
}
public void draw(Graphics2D g) {
@Override
public void Draw(Graphics2D g) {
if(_airPlane == null) return;
_airPlane.DrawTransport(g);
}