Compare commits
No commits in common. "fefd0e637ef98498a6be7708d61e7b1b15545428" and "9c05e95a9b532dc4c1d6978668d80c7d564e25cd" have entirely different histories.
fefd0e637e
...
9c05e95a9b
@ -80,32 +80,8 @@ class DrawningLocomotive {
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTransport(Graphics2D g) {
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| _pictureHeight == null || _pictureWidth == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//тело
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10);
|
||||
//окна
|
||||
g.setColor(Locomotive.getBodyColor());
|
||||
g.fillRect((int)_startPosX + 10, (int)_startPosY + 10, 10, 10);
|
||||
g.fillRect((int)_startPosX + 30, (int)_startPosY + 10, 10, 10);
|
||||
g.fillRect((int)_startPosX + 80, (int)_startPosY + 10, 10, 10);
|
||||
//дверь
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20);
|
||||
//колеса
|
||||
g.drawOval((int) _startPosX, (int)_startPosY + 40, 10, 10);
|
||||
g.drawOval((int) _startPosX + 20, (int)_startPosY + 40, 10, 10);
|
||||
g.drawOval((int) _startPosX + 70, (int)_startPosY + 40, 10, 10);
|
||||
g.drawOval((int) _startPosX + 90, (int)_startPosY + 40, 10, 10);
|
||||
//движок
|
||||
g.setColor(Locomotive.getBodyColor());
|
||||
g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30);
|
||||
|
||||
public void DrawTransport() {
|
||||
//TODO: do!
|
||||
}
|
||||
|
||||
public void ChangeBorders(int width, int height)
|
||||
|
@ -37,4 +37,10 @@ public class EntityLocomotive {
|
||||
}
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Random;
|
||||
|
||||
public class FormLocomotive extends JComponent{
|
||||
private DrawningLocomotive _locomotive;
|
||||
private EntityLocomotive _entity;
|
||||
public FormLocomotive() {
|
||||
JFrame formFrame = new JFrame("Locomotive");
|
||||
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
formFrame.setSize(800, 500);
|
||||
formFrame.setVisible(true);
|
||||
formFrame.setLocationRelativeTo(null);
|
||||
|
||||
Panel southPanel = new Panel();
|
||||
setLayout(new BorderLayout());
|
||||
add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
JButton createButton = new JButton("Create");
|
||||
createButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Random rnd = new Random();
|
||||
_locomotive = new DrawningLocomotive();
|
||||
_entity = new EntityLocomotive();
|
||||
_locomotive.Init(100 + rnd.nextInt(200), 1000 + rnd.nextInt(1000), Color.getHSBColor(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), _entity);
|
||||
_locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), formFrame.getWidth(), formFrame.getHeight());
|
||||
// toolStripStatusLabelSpeed.Text = $"Speed: {_locomotive.Locomotive.Speed}";
|
||||
// toolStripStatusLabelWeight.Text = $"Weight: {_locomotive.Locomotive.Weight}";
|
||||
// toolStripStatusLabelColor.Text = $"Color: {_locomotive.Locomotive.BodyColor.Name}";
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
|
||||
southPanel.add(createButton);
|
||||
|
||||
formFrame.getContentPane().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
if (_locomotive != null) _locomotive.DrawTransport(g2);
|
||||
super.repaint();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
FormLocomotive formLocomotive = new FormLocomotive();
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user