JOGRE development with Eclipse
|
|
Last Updated:
6th March, 2006, 16:05 GMT
|
|
Contents
|
|
|
|
|
Introduction to Eclipse
|
|
|
Eclipse is a very powerful open source plugin based IDE. The majority
of implementation of the JOGRE source code has been done using Eclipse. To download
a version of Eclipse click here
for a link to their offical website and download a 3+ version.
When you load Eclipse for the first time you may be in the Resource
perspective (indicated by a button on the top right hand side of the screen). If this
is the case then close all the perspectives (Window - Close all perspectives) and
open the Java perspective (Window - Open Perspective - Java). You
should now see something like the following screenshot:
|
|
|
|
The first step required to get stuck into some JOGRE programming is to create
a new project.
|
|
[ top ] |
|
|
Creating a project for the JOGRE API
|
|
|
To start programming in Eclipse on the JOGRE API you first of
all must download the JOGRE source code. Click
here for a link to the download page and download JOGRE Alpha 0.2.3.
To create a new project select File - New - Project from the menu.
A dialog should appear. Select Java Project and click Next >.
|
|
|
|
In the next screen the Project name must be set to something like
JOGRE API and the location set to where the JOGRE source has been
extracted to (e.g. c:\jogre\api). Click Next > again.
|
|
|
|
The last screen to appear is where you can set your source folder,
output folder, projects and classes which are on the classpath. Ensure that
the Default output folder box (on the Source tab) is set to JOGRE API/classes as
in the following screenshot.
|
|
|
|
The JOGRE API doesn't have any project/jar file dependancies
(apart from the Sun Java JDK) so ensure that the jogre.jar
isn't in the build path (on the Libraries tab). You should have a screen
like the following. Click the Finish button to complete the creation
of the project.
|
|
|
|
If everything was successful you should see the project on the
left hand side of the screen and be able to edit all the files from the
JOGRE API.
|
|
|
|
|
[ top ] |
|
|
Creating a project for a JOGRE game
|
|
|
To create a new project in Eclipse for implementing a game the source code
download isnt required (although it is useful to see how some of
the other games were created). To create a game using JOGRE you either need
the jogre.jar file (from either the source or binaries distributions)
or have the JOGRE API set up as a project (see previous section
for details on this). This section will explain both approaches.
Create a new project (File - New - Project) and give it a suitable name
(e.g. JOGRE Dominos). Game projects are stored under the jogre/games directory.
Also ensure that the Create separate source and output folders is
selected.
|
|
|
|
Click Next > and ensure the Default Output folder
is set to [Project Name]/classes.
The JOGRE API must now be included on the build path (CLASSPATH). This can be done
from either including the JOGRE API project (see previous section) or by including
the jogre.jar file. To add the JOGRE API project select the Projects
tab and add the JOGRE API project as illustrated in the following screenshot.
|
|
|
|
If you have only downloaded the binaries distribution you can simply add
the jogre.jar file. Click on the Libraries tab and select the
Add external JARs button to add the jar which is located in
/jogre/api/jogre.jar. Click the Finish button to complete
Project creation.
|
|
|
|
Once the game project is created you should have something like the
following (left is created from project, right is created from JAR file).
|
|
|
|
Note: If you creating server controllers you must include the
jogre/server/server.jar (or link to a Jogre Server project). This
is discussed in "connect 4" tutorial.
The last task to do before creating classes is to create a suitable
package. When creating a new game most of the classes are stored in the
org.jogre.name_of_game.client package. To
create a new package select File - New - Package
to get a dialog like the following:
|
|
|
|
For more information on making a game check out the
tutorials.
|
|
[ top ] |
|
|
Creating a project for the JOGRE Server
|
|
|
Creating a project for the JOGRE Server in Eclipse is quite easy. It
depends on the JOGRE API and some libraries (which are stored in the
/jogre/server/lib directory.
Now you can create a project by supplying a name like JOGRE Server
and the location /jogre/server as follows:
|
|
|
|
Ensure once again the the Default output folder points to the
classes directory and that the build path includes the JOGRE API.
If the project has been created successfully there should be no compile errors
(a compile error indicates the path isn't set up correctly).
|
|
|
|
The jogre/server/server.xml file can be customised to inform the server of which
clients to support. This is done by adding a new <game> element as a child of
<supported_games>. E.g. for dominoes:
<game id="dominoes" minPlayers="2" maxPlayers="4"/>
The server can now be run from the /jogre/server/server.bat batch file
or through Eclipse by click on menu option Run - Run... and then selecting
Java Application and clicking the New button. Fill in the options
as shown on the following screenshot and hit the Run button.
|
|
|
|
If running through Eclipse ensure that the jogre/server/server.properties file
has been copied to the jogre/server/classes output folder, otherwise a missing resources
exception may appear. If the server runs sucessfully you should see the following
in the console view in Eclipse:
|
|
|
|
As you can see the dominoes class has appeared as a game. If you create a
server controller for it the [controller] tag will appear to its left. Check out the
connect 4 tutorial for more information.
|
|
[ top ] |
|
|
Conclusion
|
|
|
This concludes this document on how to set up Eclipse for development of JOGRE.
Eclipse is highly recommended by many people and is by far my favourite IDE for its
power, ease of use and helpful features. If you have any suggestions or queries
about this document then feel free to contact the author
Bob Marks.
|
|
[ top ] |
|
|