jMonkeyEngine 3.0 Beginner’s Guide
上QQ阅读APP看书,第一时间看更新

Chapter 3. Interacting with the User

The main loop is your game's Dungeon Master, referee, and director: it listens for user input, updates the game state, and renders the output. In a game of Blockout, the loop drops blocks and clears finished layers. In a car racer, the loop calculates friction and acceleration. In a first-person shooter, the loop respawns enemies. The loop is where you make sure everyone sticks to the rules, and where you determine whether the player has won or lost.

In the previous chapter, we learnt how to initialize a 3D scene using the simpleInitApp() method from the SimpleApplication class. You can translate, scale, and rotate objects into their start positions, and navigate the scene using the mouse and W, A, S, and D keys. But the scene is still static—we need some interaction!

In this chapter you will learn:

  • How to respond to user input
  • How to determine the target of a user action
  • How to trigger game actions
  • How to steer game characters

Let's make the application come alive.