The JME3 Development Environment
The JME3 development environment is based on NetBeans. If you are familiar with this environment, then JME3 will be easy to pickup. If not, then you should not have much difficulty using JME3 as it is well organized. We will point out those features that you are most likely to encounter when developing your game.
Figure 1 – JME3 SDK shows the initial JME3 window. In this section we will cover the basic components of the system and how to use them. As you progress through the book we will introduce other useful features including screen snapshots of important menu and dialog selections.
Many features of the SDK are accessed using the file menu or access keys. The Project Window will display the relevant parts of a project such as its assets and files. We will learn more about this structure in this chapter. The Info Screen found in the middle of the SDK is replaced by your game’s file contents when developing the application. While console tab Output – Application is not used directly in a game, it is can be useful for debugging purposes.
Figure 1 – JME3 SDK
Once you have set up JME3 and understand its basics, you are ready to start the game development process. Important JME3 links to assist you in your development effort are listed in Table 1 – JME3 Useful Links.
Table 1 – JME3 Useful Links
|Main JME3 Site||http://hub.jmonkeyengine.org/tag/jme3/|
Structure of a JME3 Application
A JME3 application is derived from the class SimpleApplication. This class provides the standard methods to support a game’s lifecycle plus a number of variables to provide access to important features of a game. These methods and variables are detailed in Table 2 – SimpleApplication Useful Methods and Variables. In the next section we will explain the essential methods and variables used in a basic game. In later chapters we will expand upon the remaining methods and variables and introduce other methods and variables as they become useful.
Table 2 – SimpleApplication Useful Methods and Variables
|main||The starting point for Java applications and JME3 games|
|simpleInitApp||Used to initialize the game|
|simpleUpdate||Used to update the state of the game|
|simpleRender||Used to render unique GUI elements of a game|
|destroy||Supports game termination tasks|
|assetManager||Used to manage the game’s assets such as its objects and their appearance|
|rootNode||The root of the game’s elements|
|guiNode||Used to support the Heads Up Display (HUD)|
The BasicGame Project
JME3 provides a simple game project called BasicGame. This game can be created using the File – New Project menu selection. Go ahead and start up JME3. Use this menu selection to create a game. The New Dialog box should appear as illustrated in Figure 2 – New Project Dialog Box. Select BasicGame and then the Next button.
Figure 2 – New Project Dialog Box
The next dialog box will appear as shown in Figure 3 – Name and Location Dialog Box. Leave the name as it is and select Finish.
Figure 3 – Name and Location Dialog Box
Expand the BasicGame project by clicking on the + in the Project window. Expand the Source Packages and mygame folders also. Double click on Main.java and this will display the source code for the game. Alternately, you can right click on the file and select Open. When you have done this, your project should appear as shown in Figure 4 – BasicGame Project.
Figure 4 – BasicGame Project
Execute the game by either pressing the F6 key, the Run Project button (the green arrow) or select the menu combination Run – Run Project. The game will appear with a blue cube located at its origin as shown in Figure 5 – BasicGame Executing. To terminate the game, use the escape key.
The text on the bottom left-hand side of the game is the default Heads Up Display (HUD). A HUD is a convenient technique to display information about the state of a game. In the default game it displays basic information about the GUI. The HUD will be discussed in more detail in Using the HUD.
Figure 5 – BasicGame Executing
For the user to interact with the game, some sort of input device is needed. Often this is a combination of the keyboard and mouse. The keys are referred to as Navigation keys. When the game is started, the default navigation is in effect as described in Table 3 – Navigation Keys. Assuming the player is at the same position as the camera, the effect of the navigation keys can be interpreted as the camera and the player moving. That is, the view is from the perspective of the player. As the player moves, the camera moves. This is reflected in the last two columns of the table.
Table 3 – Navigation Keys
|W and S keys||Moves forward and backward||Walks back and forth|
|A and D keys||Moves left and right||Walks left and right|
|Q and Y keys||Moves up and down||Flies up and down|
|Mouse left and right||Rotates left and right||Looks left and right|
|Mouse forward and backward||Rotates up and down||Looks up and down|
This content has been taken from Chapter 1 of jMonkeyEngine 3.0 Game Development: A Practical Guide