Time for action – you are the CubeChaser

Let's do something more interactive than just look at rotating cubes. Can you write code that lets you chase one of the cubes? By chase we mean, if the camera moves closer than 10 WU to this cube, the cube should move away from the camera.

  1. Make another copy of the BasicGame object's Main.java template.
  2. Rename the copy to CubeChaser.java. Remember to also refactor the first line of the main() method to the following:
    CubeChaser app = new CubeChaser();
  3. Delete the blue cube and copy the myBox() convenience method from one of the previous target picking examples. Don't forget to copy the mesh class field.
  4. Add a makeCubes(40); call to the simpleInitApp() method and fill the scene with 40 randomly positioned and randomly ...

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.