Tutorials/Eclipse

From FANG

Jump to: navigation, search

This tutorial shows you how to use the FANG Engine with Eclipse. The screenshots for this tutorial are taken in Eclipse 3.4.2 on Mac OS X 10.5. Your version of Eclipse on your operating system may look slightly different, but the procedure should be roughly the same. Consult the Eclipse web page for detailed documentation on your own version of Eclipse.

  1. Download the latest version of the FANG Engine. There are two types of downloads - the compiled version and the source code version.
    Download the compiled version.
  2. Open up Eclipse and start a new Java Project. To start a new project, go to File->New->Java Project. A dialog with several screens (the first is shown below) will come up.
    Click Next.
  3. On the second screen of the dialog, enter Wacky in the Project name field, as shown on the right.
    In the JRE section of this dialog, make sure you have Java 1.5 or higher selected (nearly all version are like this by default). If the option instead says something else (such as Currently 1.4), then click on the link to the right of the option that says Configure default.... Follow the instructions for changing to 1.5 or higher.
  4. In Eclipse right click on src within Wacky in the Package Explorer then select Build Path->Add External Archives...
    You will then see the screen shown on the right.
  5. Find and select the jar file you downloaded at the beginning of this step, then click on Open
  6. Create a new class by right clicking in the src folder and selecting New->Class.
  7. In the dialog that comes up, put fang2.core.Game in the Superclass field.
    Name your class whatever you would like. This example is from the Wackadot tutorial, so it is called Wackadot.
  8. Some code will be automatically generated when you create the Wackadot class. Replace the generated code with the code in the table below.
A
Source code
Explanation of Source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package wackadot;


import fang.*;
import java.awt.*;
import java.awt.geom.*;

/**
* All about my game here.
* @author YourName
*/
public class Wackadot extends GameLoop
{
   public static void main(String[] argv)
   {
      Wackadot dot=new Wackadot();
      dot.runAsApplication();
   }
}

Line 1: the package this class is in

Line 4: importing the fang package for use in the class.

Lines 14-18: the main method is required to allow the game to be run as an application in addition to it being an applet. (It is an applet because it is derived from the GameLoop class which is indirectly derived from the JApplet class.)


  1. Running the Game

The method runAsApplication in main is what starts the game running. (The method is from the FANG engine.)

There are three ways to run your game: as an applet, as an application, and as a networked game. For now we are going to run Wackadot as an application. To do this, highlight the Wackadot class in the Package Explorer, right click, then select Run As... and then select Java Application.

You should see a window come up that looks like the image in this section.





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games