Time for action – falling bricks

With what you have learned, you can create a scene with a floor, build a wall out of brick geometries, and shoot some cannon balls at it.

  1. Make a copy of Main.java and name the class PhysicsFallingBricks.java. Remember to also refactor the first line of the main() method to:
    PhysicsFallingBricks app = new PhysicsFallingBricks();
  2. Make this a physical game by attaching a BulletAppState instance.
    private BulletAppState bulletAppState;
    @Override
    public void simpleInitApp() {
      bulletAppState = new BulletAppState();
      stateManager.attach(bulletAppState);
    }
  3. Prepare some class fields for the objects in your scene. The scene uses boxes for the bricks, spheres for the cannon balls, and another box for the floor. You also prepare ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.