Commits

Meitian Huang  committed 50983e7

End of a day

  • Participants
  • Parent commits 28a27d1

Comments (0)

Files changed (5)

File src/Game/Handler.java

 
     public void resetGame();
 
+    public void restartGame();
+
     public void stopGame();
 
     public void loseGame();
+
+    public float getBoardThickness();
 }

File src/Game/Hole.java

     @Override
     public void attach() {
         cylinderCollisionShape =
-                new CylinderCollisionShape(new Vector3f(radius, 0.02f, 0.1f), 1);
+                new CylinderCollisionShape(
+                        new Vector3f(radius, handler.getBoardThickness(), 0.1f),
+                        1);
         handler.addShapeToBase(cylinderCollisionShape, location);
     }
 

File src/Game/Key.java

             } else if (name.equals("Quit") && !pressed) {
                 handler.stopGame();
             } else if (name.equals("Change") && !pressed) {
-                handler.resetGame();
+                handler.restartGame();
             }
         }
     };

File src/Game/Maze.java

 
         initHandler();
         score = new Score(handler);
-
         initWorld();
         setupKeys();
     }
         handler = new Handler() {
             public void rotateBoard(float x, float y, float z) {
                 if (!isLost) {
-                    boardNode.rotate(x * pref.sensitivity, y * pref.sensitivity, z * pref.sensitivity);
+                    boardNode.rotate(x * pref.sensitivity,
+                                     y * pref.sensitivity,
+                                     z * pref.sensitivity);
                 }
             }
 
                 bulletAppState.getPhysicsSpace().add(rigidBodyControl);
             }
 
-            public void addShapeToBase(BoxCollisionShape boxCollisionShape, Vector3f location) {
+            public void addShapeToBase(BoxCollisionShape boxCollisionShape,
+                                       Vector3f location) {
                 base.addChildShape(boxCollisionShape, location);
             }
 
-            public void addShapeToBase(CylinderCollisionShape cylinderCollisionShape, Vector3f location) {
+            public void addShapeToBase(CylinderCollisionShape cylinderCollisionShape,
+                                       Vector3f location) {
                 base.addChildShape(cylinderCollisionShape, location);
             }
 
                 reset();
             }
 
+            public void restartGame() {
+                pref.init();
+                reset();
+            }
+
             public void stopGame() {
                 stop();
             }
                 System.out.println("You lose!");
                 stop();
             }
+
+            public float getBoardThickness() {
+                return pref.boardHeight;
+            }
         };
     }
 
         ball.setLocation(pref.ballPosition);
         ball.setRadius(pref.ballRadius);
         ball.attach();
+
+        if (pref.bugMe) {
+            Ball ball2 = new Ball(handler);
+            ball2.setLocation(pref.ballPosition.negate().add(new Vector3f(0, 0.4f, 0)));
+            ball2.setRadius(pref.ballRadius * 2);
+            ball2.attach();
+        }
     }
 
     private void finalise() {
             score.increaseScore(timeLeft);
             score.reduceScore((int) time / 10);
             pref.increaseLevel();
+            pref.init();
             reset();
             time = 0;
         }
     }
 
     public void reset() {
-        pref.init();
         bulletAppState.getPhysicsSpace().remove(board);
         boardNode.removeFromParent();
 
         initHoles();
         initEnd();
 
-        ball.setPhysicsLocation(
-                pref.ballPosition);
+        ball.setPhysicsLocation(pref.ballPosition);
     }
 }

File src/Game/Pref.java

     protected Vector3f endPosition;
 
     private DFS dfs;
+    protected boolean bugMe = true;
 
     public Pref() {
         level = 1;