Loading src/main/java/Shape/Obstacle.java +4 −10 Original line number Diff line number Diff line package Shape; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.*; import java.util.ArrayList; import java.util.HashSet; import java.util.Random; import java.util.Set; public class Obstacle { public Obstacle(int WindowSize, double xTranslation, double yTranslation, Loading @@ -27,7 +21,7 @@ public class Obstacle { this.shape.setTranslateX(xTranslation); this.shape.setTranslateY(yTranslation); this.shape.setTranslateZ(zTranslation); this.immovable = immovable; this.removable = immovable; shapeBound = this.shape.getBoundsInParent(); } Loading Loading @@ -55,8 +49,8 @@ public class Obstacle { } public String checkCollision(Bounds otherBounds) { if (shapeBound.intersects(otherBounds)) { if(immovable){ return "IMMOVABLE"; if(removable){ return "REMOVABLE"; } double deltaX = Math.min(shapeBound.getMaxX() - otherBounds.getMinX(), otherBounds.getMaxX() - shapeBound.getMinX()); double deltaY = Math.min(shapeBound.getMaxY() - otherBounds.getMinY(), otherBounds.getMaxY() - shapeBound.getMinY()); Loading Loading @@ -85,7 +79,7 @@ public class Obstacle { } return "NONE"; } boolean immovable; boolean removable; int WindowSize = 0; double xTranslation, yTranslation, zTranslation; Node shape; Loading src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,10 @@ public class GraphicsAndWindowsTest extends Application { if(!(collisionSide.get(0).equals("NONE"))){ Bounds obBounds = ((Obstacle) collisionSide.get(1)).getShape().getBoundsInParent(); switch ((String)collisionSide.get(0)){ case "REMOVABLE": Obstacle o = ((Obstacle) collisionSide.get(1)); break; case "LEFT": direction[i][0] = abs(direction[i][0]); break; Loading target/classes/Shape/MovingObject.class +138 B (6.1 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
src/main/java/Shape/Obstacle.java +4 −10 Original line number Diff line number Diff line package Shape; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.*; import java.util.ArrayList; import java.util.HashSet; import java.util.Random; import java.util.Set; public class Obstacle { public Obstacle(int WindowSize, double xTranslation, double yTranslation, Loading @@ -27,7 +21,7 @@ public class Obstacle { this.shape.setTranslateX(xTranslation); this.shape.setTranslateY(yTranslation); this.shape.setTranslateZ(zTranslation); this.immovable = immovable; this.removable = immovable; shapeBound = this.shape.getBoundsInParent(); } Loading Loading @@ -55,8 +49,8 @@ public class Obstacle { } public String checkCollision(Bounds otherBounds) { if (shapeBound.intersects(otherBounds)) { if(immovable){ return "IMMOVABLE"; if(removable){ return "REMOVABLE"; } double deltaX = Math.min(shapeBound.getMaxX() - otherBounds.getMinX(), otherBounds.getMaxX() - shapeBound.getMinX()); double deltaY = Math.min(shapeBound.getMaxY() - otherBounds.getMinY(), otherBounds.getMaxY() - shapeBound.getMinY()); Loading Loading @@ -85,7 +79,7 @@ public class Obstacle { } return "NONE"; } boolean immovable; boolean removable; int WindowSize = 0; double xTranslation, yTranslation, zTranslation; Node shape; Loading
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,10 @@ public class GraphicsAndWindowsTest extends Application { if(!(collisionSide.get(0).equals("NONE"))){ Bounds obBounds = ((Obstacle) collisionSide.get(1)).getShape().getBoundsInParent(); switch ((String)collisionSide.get(0)){ case "REMOVABLE": Obstacle o = ((Obstacle) collisionSide.get(1)); break; case "LEFT": direction[i][0] = abs(direction[i][0]); break; Loading
target/classes/Shape/MovingObject.class +138 B (6.1 KiB) File changed.No diff preview for this file type. View original file View changed file