Commit 29054ad9 authored by Timothy  Borunov's avatar Timothy Borunov
Browse files

Obstacle bugged

parent e56ab52a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class GraphicsAndWindowsTest extends Application {


        ObstacleField obs = new ObstacleField(sceneWindow.getWindowSize(),sceneWindow.getXOffset(),
                sceneWindow.getYOffset(),350,50, 100, 60, "Box",
                sceneWindow.getYOffset(),300,-250, 1000, 30, "Box",
                Color.ORANGERED, false);

        String[] ob2 = {"--image", "src/teapot.txt", "--speed", "32", "--dir", "4,", "7,", "10"};
@@ -74,6 +74,7 @@ public class GraphicsAndWindowsTest extends Application {


        Group group3D = new Group(); // Group of our 3D elements
        obs.addToGroup(group3D);
        for (MovingObject o : objects ) {
            o.setTranslate(sceneWindow.getXOffset(), sceneWindow.getYOffset(),0);
            group3D.getChildren().add(o.getMesh());
@@ -84,7 +85,7 @@ public class GraphicsAndWindowsTest extends Application {
        group3D.setTranslateZ(250);
        group3D.getChildren().add(ourWindow);
        group3D.getChildren().add(new AmbientLight(Color.WHITE));
        obs.addToGroup(group3D);


        // NOTE: Due to the perspectiveCamera it looks like it is rotating even though it isn't
        // If you comment out this line and the scene.setCamera(camera) line
@@ -234,7 +235,6 @@ public class GraphicsAndWindowsTest extends Application {
                            }
                            direction[i][0] *= -1;
                            lastChanged = 1;

                        }

                        // Window Collision computation for Y
@@ -265,6 +265,7 @@ public class GraphicsAndWindowsTest extends Application {

                        List<Object> collisionSide = obs.checkCollision(meshBounds[i]);
                        if(!(collisionSide.get(0).equals("NONE"))){
                            Bounds obBounds = ((Obstacle) collisionSide.get(1)).getShape().getBoundsInParent();
                            switch ((String)collisionSide.get(0)){
                                case "LEFT":
                                    direction[i][0] = abs(direction[i][0]);
@@ -275,6 +276,7 @@ public class GraphicsAndWindowsTest extends Application {
                                    break;

                                case "TOP":
                                    y = direction[i][1] - (obBounds.getMaxY() + (meshBounds[i].getMinY() + y));
                                    direction[i][1] =  abs(direction[i][1]);
                                    break;