Принятая лабораторная
This commit is contained in:
parent
33ef22cccc
commit
92be17d6f6
@ -1,5 +1,4 @@
|
|||||||
public enum Direction {
|
public enum Direction {
|
||||||
|
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
Left,
|
Left,
|
||||||
|
@ -120,15 +120,10 @@ public class DrawningBattleship {
|
|||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
|
|
||||||
//Корпус корабля
|
//Корпус корабля
|
||||||
//Brush br = new SolidBrush(Battleship?.BodyColor ?? Color.Black);
|
|
||||||
// Polygon[] shipHullArrayPoints = {((int)_startPosX, (int)_startPosY)), (int)_startPosX, (int)_startPosY + 50), new Point((int)_startPosX + 80, (int)_startPosY + 50),
|
|
||||||
//(int)_startPosX + 120, (int)_startPosY + 25 ), new Point((int)_startPosX + 80, (int)_startPosY), new Point((int)_startPosX, (int)_startPosY)};
|
|
||||||
g.setColor(Battleship.bodyColor);
|
g.setColor(Battleship.bodyColor);
|
||||||
g.fillPolygon(new int[]{(int) _startPosX, (int) _startPosX , (int) _startPosX+80, (int) _startPosX + 120, (int)_startPosX + 80, (int)_startPosX},
|
g.fillPolygon(new int[]{(int) _startPosX, (int) _startPosX , (int) _startPosX+80, (int) _startPosX + 120, (int)_startPosX + 80, (int)_startPosX},
|
||||||
new int[]{(int) _startPosY, (int) _startPosY+50 , (int) _startPosY+50, (int) _startPosY + 25, (int)_startPosY, (int)_startPosY}, 6);
|
new int[]{(int) _startPosY, (int) _startPosY+50 , (int) _startPosY+50, (int) _startPosY + 25, (int)_startPosY, (int)_startPosY}, 6);
|
||||||
|
|
||||||
//Пушка
|
//Пушка
|
||||||
|
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
g.drawRect((int)_startPosX + 20, (int)_startPosY + 20, 30, 10);
|
g.drawRect((int)_startPosX + 20, (int)_startPosY + 20, 30, 10);
|
||||||
g.drawRect((int)_startPosX + 50,(int) _startPosY + 10, 20, 30);
|
g.drawRect((int)_startPosX + 50,(int) _startPosY + 10, 20, 30);
|
||||||
@ -150,8 +145,6 @@ public class DrawningBattleship {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
|
|
||||||
|
|
||||||
public void ChangeBorders(int width, int height)
|
public void ChangeBorders(int width, int height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
@ -171,5 +164,4 @@ public class DrawningBattleship {
|
|||||||
_startPosY = _pictureHeight - _battleshipHeight;
|
_startPosY = _pictureHeight - _battleshipHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ public class DrawningBlocks {
|
|||||||
else {
|
else {
|
||||||
blocksCount = DirectionBlocksOnDeck.Two;
|
blocksCount = DirectionBlocksOnDeck.Two;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void Init(int blocksCount, Color color)
|
public void Init(int blocksCount, Color color)
|
||||||
{
|
{
|
||||||
@ -36,7 +34,6 @@ public class DrawningBlocks {
|
|||||||
g.fillRect(x + 38, y + 35, 10, 5);
|
g.fillRect(x + 38, y + 35, 10, 5);
|
||||||
g.fillRect(x + 26, y + 35, 10, 5);
|
g.fillRect(x + 26, y + 35, 10, 5);
|
||||||
g.fillRect(x + 14, y + 35, 10, 5);
|
g.fillRect(x + 14, y + 35, 10, 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.awt.event.ActionListener;
|
|||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class FormBattleship extends JComponent {
|
public class FormBattleship extends JComponent {
|
||||||
private DrawningBattleship _battleship;
|
private DrawningBattleship _battleship;
|
||||||
private EntityBattleship _entityBattleship;
|
private EntityBattleship _entityBattleship;
|
||||||
@ -27,20 +26,16 @@ public class FormBattleship extends JComponent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentMoved(ComponentEvent e) {
|
public void componentMoved(ComponentEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentHidden(ComponentEvent e) {
|
public void componentHidden(ComponentEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Panel statusPanel = new Panel();
|
Panel statusPanel = new Panel();
|
||||||
statusPanel.setBackground(Color.WHITE);
|
statusPanel.setBackground(Color.WHITE);
|
||||||
statusPanel.setLayout(new FlowLayout());
|
statusPanel.setLayout(new FlowLayout());
|
||||||
@ -65,10 +60,8 @@ public class FormBattleship extends JComponent {
|
|||||||
weightLabel.setText("Вес: " + (int)_battleship.Battleship.GetWeight());
|
weightLabel.setText("Вес: " + (int)_battleship.Battleship.GetWeight());
|
||||||
colorLabel.setText("Цвет: " + _battleship.Battleship.GetBodyColor().getRed() + " " +
|
colorLabel.setText("Цвет: " + _battleship.Battleship.GetBodyColor().getRed() + " " +
|
||||||
_battleship.Battleship.GetBodyColor().getGreen() + " " + _battleship.Battleship.GetBodyColor().getBlue() );
|
_battleship.Battleship.GetBodyColor().getGreen() + " " + _battleship.Battleship.GetBodyColor().getBlue() );
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
statusPanel.add(createButton);
|
statusPanel.add(createButton);
|
||||||
statusPanel.add(speedLabel);
|
statusPanel.add(speedLabel);
|
||||||
@ -101,7 +94,6 @@ public class FormBattleship extends JComponent {
|
|||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
statusPanel.add(leftButton);
|
statusPanel.add(leftButton);
|
||||||
statusPanel.add(upButton);
|
statusPanel.add(upButton);
|
||||||
statusPanel.add(rightButton);
|
statusPanel.add(rightButton);
|
||||||
|
Loading…
Reference in New Issue
Block a user