From bd8607a79629db4679a7d9a0e4f47ba05a57e61f Mon Sep 17 00:00:00 2001 From: Zyzf Date: Mon, 21 Nov 2022 11:19:46 +0400 Subject: [PATCH] some changes --- .../ControllerBoat.java | 19 +- .../ControllerMap.java | 181 ++++++++++++++++++ .../DrawningBoat.java | 10 +- .../DrawningLongOars.java | 111 +++++++++++ .../DrawningObjectBoat.java | 49 +++++ .../DrawningShortOars.java | 166 ++++++++++++++++ .../IDrawningAdditionalElement.java | 2 +- .../MySecondMap.java | 38 ++++ .../form-boat-view.fxml | 112 +---------- .../form-map-view.fxml | 21 +- 10 files changed, 582 insertions(+), 127 deletions(-) create mode 100644 src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerMap.java create mode 100644 src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningLongOars.java create mode 100644 src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningObjectBoat.java create mode 100644 src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningShortOars.java create mode 100644 src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/MySecondMap.java diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerBoat.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerBoat.java index bcc3944..04b7f5c 100644 --- a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerBoat.java +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerBoat.java @@ -26,9 +26,9 @@ public class ControllerBoat { @FXML private Label labelBodyColorValue; @FXML - private ComboBox comboBoxNumOfRollers; + private ComboBox comboBoxNumOars; @FXML - private ComboBox comboBoxOrnamentType; + private ComboBox comboBoxOarsType; @FXML private Button buttonCreate; @FXML @@ -124,7 +124,7 @@ public class ControllerBoat { { if (_boat != null) { - _boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOfRollers.getValue())); + _boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue())); Draw(); } } @@ -133,18 +133,17 @@ public class ControllerBoat { { if (_boat != null) { - IDrawningAdditionalElement newDrawningTrackRollers = switch (comboBoxOrnamentType.getValue()) + IDrawningAdditionalElement newDrawningOars = switch (comboBoxOarsType.getValue()) { case "None" -> new DrawningOars(_boat.GetBoat().GetBodyColor()); - case "Dots" -> new DrawningDotOrnamentTrackRollers(_boat.GetBoat().GetBodyColor()); - case "Circles" -> - new DrawningCircleOrnamentTrackRollers(_boat.GetBoat().GetBodyColor()); + case "Short" -> new DrawningShortOars(_boat.GetBoat().GetBodyColor()); + case "Long" -> new DrawningLongOars(_boat.GetBoat().GetBodyColor()); default -> null; }; - if (newDrawningTrackRollers != null) + if (newDrawningOars != null) { - _boat.SetDrawningOars(newDrawningTrackRollers); - _boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOfRollers.getValue())); + _boat.SetDrawningOars(newDrawningOars); + _boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue())); } } } diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerMap.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerMap.java new file mode 100644 index 0000000..999a976 --- /dev/null +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/ControllerMap.java @@ -0,0 +1,181 @@ +package com.example.pibd22_kalyshev_y_v_motorboat_hard; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; + +import java.util.Random; + +public class ControllerMap +{ + @FXML + private Pane root; + @FXML + private Canvas canvas; + @FXML + private FlowPane flowPane; + @FXML + private Label labelSpeedValue; + @FXML + private Label labelWeightValue; + @FXML + private Label labelBodyColorValue; + @FXML + private ComboBox comboBoxNumOars; + @FXML + private ComboBox comboBoxOarsType; + @FXML + private ComboBox comboBoxSelectorMap; + @FXML + private Button buttonCreate; + @FXML + private Button buttonCreateModif; + @FXML + private Button buttonLeft; + @FXML + private Button buttonRight; + @FXML + private Button buttonUp; + @FXML + private Button buttonDown; + private final double buttonMargin = 10.0; + private AbstractMap _abstractMap; + + @FXML + public void initialize() + { + buttonCreate.setTranslateX(buttonMargin); + + root.widthProperty().addListener((obs, oldVal, newVal) -> + { + UpdateGUI(); + if (_abstractMap != null) + { + _abstractMap.DrawMapWithObject(); + } + }); + root.heightProperty().addListener((obs, oldVal, newVal) -> + { + UpdateGUI(); + if (_abstractMap != null) + { + _abstractMap.DrawMapWithObject(); + } + }); + } + + @FXML + void ButtonCreate_Click() + { + Random rnd = new Random(); + DrawningBoat boat = new DrawningBoat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); + SetData(boat); + } + + @FXML + void ButtonCreateModif_Click() + { + Random rnd = new Random(); + DrawningSpeedboat boat = new DrawningSpeedboat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), + Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), + (rnd.nextInt(2) != 0), (rnd.nextInt(2) != 0), (rnd.nextInt(2) != 0)); + SetData(boat); + } + + @FXML + void ButtonMove_Click(ActionEvent event) + { + if (_abstractMap == null) + { + return; + } + String buttonName = ((Button) event.getSource()).getId(); + switch (buttonName) + { + case "buttonUp" -> _abstractMap.MoveObject(Direction.Up); + case "buttonDown" -> _abstractMap.MoveObject(Direction.Down); + case "buttonLeft" -> _abstractMap.MoveObject(Direction.Left); + case "buttonRight" -> _abstractMap.MoveObject(Direction.Right); + } + } + + @FXML + private void ComboBoxSelectorMap_Changed() + { + switch (comboBoxSelectorMap.getValue()) + { + case "Simple map" -> _abstractMap = new SimpleMap(); + case "My second map" -> _abstractMap = new MySecondMap(); + } + } + + private void ChangeDrawningOars(DrawningBoat boat) + { + IDrawningAdditionalElement newDrawningOars = switch (comboBoxOarsType.getValue()) + { + case "None" -> new DrawningOars(boat.GetBoat().GetBodyColor()); + case "Short" -> new DrawningShortOars(boat.GetBoat().GetBodyColor()); + case "Long" -> new DrawningLongOars(boat.GetBoat().GetBodyColor()); + default -> null; + }; + if (newDrawningOars != null) + { + boat.SetDrawningOars(newDrawningOars); + boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue())); + } + } + + private void UpdateGUI() + { + double sceneWidth = root.getWidth(); + double sceneHeight = root.getHeight(); + + double flowPaneHeight = flowPane.getHeight(); + double buttonCreateHeight = buttonCreate.getHeight(); + + canvas.setWidth(sceneWidth); + flowPane.setPrefWidth(sceneWidth); + canvas.setHeight(sceneHeight - flowPaneHeight); + flowPane.setTranslateY(sceneHeight - flowPaneHeight); + + buttonCreate.setTranslateY(sceneHeight - flowPaneHeight - buttonCreateHeight - buttonMargin); + buttonCreateModif.setTranslateY(sceneHeight - flowPaneHeight - buttonCreateHeight - buttonMargin); + + int buttonMoveHeight = 30; + int distanceBetweenMoveButtons = 5; + buttonUp.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight * 2.0 - buttonMargin - + distanceBetweenMoveButtons); + int buttonMoveWidth = 30; + buttonUp.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth * 2.0 - distanceBetweenMoveButtons); + + buttonDown.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin); + buttonDown.setTranslateX(sceneWidth- buttonMargin - buttonMoveWidth * 2.0 - distanceBetweenMoveButtons); + + buttonLeft.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin); + buttonLeft.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth * 3.0 - + distanceBetweenMoveButtons * 2.0); + + buttonRight.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin); + buttonRight.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth); + } + + private void SetData(DrawningBoat boat) + { + ChangeDrawningOars(boat); + labelSpeedValue.setText(Integer.toString(boat.GetBoat().GetSpeed())); + labelWeightValue.setText(Double.toString(boat.GetBoat().GetWeight())); + labelBodyColorValue.setText(boat.GetBoat().GetBodyColor().toString()); + GraphicsContext gc = canvas.getGraphicsContext2D(); + gc.clearRect(0.0, 0.0, canvas.getWidth(), canvas.getHeight()); + _abstractMap.CreateMap((int)canvas.getWidth(), (int)canvas.getHeight(), new DrawningObjectBoat(boat), gc); + } +} diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java index cf17015..225fa19 100644 --- a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java @@ -138,5 +138,13 @@ public class DrawningBoat _startPosY = _pictureHeight - _boatHeight; } } - + public float[] GetCurrentPosition() + { + float[] position = new float[4]; + position[0] = _startPosX; + position[1] = _startPosY; + position[2] = _startPosX + _boatWidth; + position[3] = _startPosY + _boatHeight; + return position; + } } diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningLongOars.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningLongOars.java new file mode 100644 index 0000000..899c5e6 --- /dev/null +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningLongOars.java @@ -0,0 +1,111 @@ +package com.example.pibd22_kalyshev_y_v_motorboat_hard; + +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; + +public class DrawningLongOars implements IDrawningAdditionalElement { + private Color _oarsColor; + private NumberOars _numOars; + + public void SetNumberOars(int numberOars) { + _numOars = NumberOars.FromInteger(numberOars); + } + public DrawningLongOars(Color oarsColor) { + _oarsColor = oarsColor; + } + public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) { + if (_oarsColor == null) { + return; + } + + gc.setFill(_oarsColor); + gc.fillOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(11.0 + startPosX, 42.0 + startPosY, 6.0, 6.0); + + gc.fillOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(95.0 + startPosX, 42.0 + startPosY, 6.0, 6.0); + + // Орнамент + gc.strokeOval(8.0 + startPosX, 39.0 + startPosY, 12.0, 12.0); + gc.strokeOval(92.0 + startPosX, 39.0 + startPosY, 12.0, 12.0); + + switch (_numOars) { + case One: + gc.setFill(_oarsColor); + gc.fillOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(40.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(68.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.strokeOval(38.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(66.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + break; + + case Two: + gc.setFill(_oarsColor); + gc.fillOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(34.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(54.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(74.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.strokeOval(32.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(52.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(72.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + break; + + case Three: + gc.setFill(_oarsColor); + gc.fillOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(30.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(46.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(62.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(78.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.strokeOval(28.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(44.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(60.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + gc.strokeOval(76.0 + startPosX, 45.0 + startPosY, 8.0, 8.0); + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningObjectBoat.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningObjectBoat.java new file mode 100644 index 0000000..4f67b36 --- /dev/null +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningObjectBoat.java @@ -0,0 +1,49 @@ +package com.example.pibd22_kalyshev_y_v_motorboat_hard; + +import javafx.scene.canvas.GraphicsContext; + +public class DrawningObjectBoat implements IDrawningObject { + private DrawningBoat _boat = null; + + public DrawningObjectBoat(DrawningBoat boat) + { + _boat = boat; + } + + public float GetStep() + { + if (_boat != null && _boat.GetBoat() != null) + { + return _boat.GetBoat().GetStep(); + } + return 0F; + } + + public float[] GetCurrentPosition() + { + if (_boat != null) + { + return _boat.GetCurrentPosition(); + } + return new float[4]; + } + + public void MoveObject(Direction direction) + { + _boat.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _boat.SetPosition(x, y, width, height); + } + + public void DrawningObject(GraphicsContext gc) + { + if (_boat != null) + { + _boat.DrawTransport(gc); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningShortOars.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningShortOars.java new file mode 100644 index 0000000..79336cc --- /dev/null +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningShortOars.java @@ -0,0 +1,166 @@ +package com.example.pibd22_kalyshev_y_v_motorboat_hard; + +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; + +public class DrawningShortOars implements IDrawningAdditionalElement { + private Color _oarsColor; + private NumberOars _numOars; + + public void SetNumberOars(int numberOars) { + _numOars = NumberOars.FromInteger(numberOars); + } + public DrawningShortOars(Color oarsColor) { + _oarsColor = oarsColor; + } + + public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) { + if (_oarsColor == null) { + return; + } + + gc.setFill(_oarsColor); + gc.fillOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(11.0 + startPosX, 42.0 + startPosY, 6.0, 6.0); + + gc.fillOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0); + gc.strokeOval(95.0 + startPosX, 42.0 + startPosY, 6.0, 6.0); + + // Орнамент + gc.setFill(Color.BLACK); + gc.fillOval(13.0 + startPosX, 38.0 + startPosY, 2.0, 2.0); + gc.fillOval(13.0 + startPosX, 50.0 + startPosY, 2.0, 2.0); + gc.fillOval(7.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(19.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + + gc.fillOval(9.0 + startPosX, 40.0 + startPosY, 2.0, 2.0); + gc.fillOval(9.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(17.0 + startPosX, 40.0 + startPosY, 2.0, 2.0); + gc.fillOval(17.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + + gc.fillOval(97.0 + startPosX, 38.0 + startPosY, 2.0, 2.0); + gc.fillOval(97.0 + startPosX, 50.0 + startPosY, 2.0, 2.0); + gc.fillOval(91.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(103.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + + gc.fillOval(93.0 + startPosX, 40.0 + startPosY, 2.0, 2.0); + gc.fillOval(93.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(101.0 + startPosX, 40.0 + startPosY, 2.0, 2.0); + gc.fillOval(101.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + + switch (_numOars) { + case One: + gc.setFill(_oarsColor); + gc.fillOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(40.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(68.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.setFill(Color.BLACK); + gc.fillOval(37.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(45.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(41.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(41.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(65.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(73.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(69.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(69.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + break; + + case Two: + gc.setFill(_oarsColor); + gc.fillOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(34.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(54.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(74.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.setFill(Color.BLACK); + gc.fillOval(31.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(39.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(35.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(35.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(51.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(59.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(55.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(55.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(71.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(79.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(75.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(75.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + break; + + case Three: + gc.setFill(_oarsColor); + gc.fillOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(30.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(46.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(62.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + gc.setFill(_oarsColor); + gc.fillOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.strokeOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0); + gc.setFill(Color.BLACK); + gc.fillOval(78.0 + startPosX, 47.0 + startPosY, 4.0, 4.0); + + // Орнамент + gc.setFill(Color.BLACK); + gc.fillOval(27.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(35.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(31.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(31.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(43.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(51.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(47.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(47.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(59.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(67.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(63.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(63.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + + gc.fillOval(75.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(83.0 + startPosX, 48.0 + startPosY, 2.0, 2.0); + gc.fillOval(79.0 + startPosX, 44.0 + startPosY, 2.0, 2.0); + gc.fillOval(79.0 + startPosX, 52.0 + startPosY, 2.0, 2.0); + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/IDrawningAdditionalElement.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/IDrawningAdditionalElement.java index 3ed22ab..13385db 100644 --- a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/IDrawningAdditionalElement.java +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/IDrawningAdditionalElement.java @@ -5,6 +5,6 @@ import javafx.scene.canvas.GraphicsContext; public interface IDrawningAdditionalElement { public int deltaYdown = 0; - public void SetNumberOars(int numberOfRollers); + public void SetNumberOars(int numberOars); public void DrawOars(GraphicsContext gc, float startPosX, float startPosY); } \ No newline at end of file diff --git a/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/MySecondMap.java b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/MySecondMap.java new file mode 100644 index 0000000..2613f81 --- /dev/null +++ b/src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/MySecondMap.java @@ -0,0 +1,38 @@ +package com.example.pibd22_kalyshev_y_v_motorboat_hard; + +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; + +public class MySecondMap extends AbstractMap +{ + protected void DrawBarrierPart(GraphicsContext gc, int i, int j) + { + gc.setFill(Color.RED); + gc.fillRect(i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + protected void DrawRoadPart(GraphicsContext gc, int i, int j) + { + gc.setFill(Color.rgb(242, 242, 242)); + gc.fillRect(i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + + protected void GenerateMap() { + _map = new int[150][100]; + _size_x = (float)_width / _map.length; + _size_y = (float)_height / _map[0].length; + int counter = 0; + for (int i = 0; i < _map.length; ++i) { + for (int j = 0; j < _map[i].length; ++j) { + _map[i][j] = _freeRoad; + } + } + while (counter < 10) { + int x = _random.nextInt(0, _map.length); + int y = _random.nextInt(0, _map[0].length); + if (_map[x][y] == _freeRoad) { + _map[x][y] = _barrier; + counter++; + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-boat-view.fxml b/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-boat-view.fxml index 778cd1a..0f92a60 100644 --- a/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-boat-view.fxml +++ b/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-boat-view.fxml @@ -37,24 +37,24 @@ - + - - - + + + - + - - + + @@ -93,100 +93,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-map-view.fxml b/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-map-view.fxml index 644ace1..dd71b9f 100644 --- a/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-map-view.fxml +++ b/src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/form-map-view.fxml @@ -34,26 +34,26 @@ - - + - - - + + + - + - - + + @@ -62,8 +62,7 @@ - - +