Free Web Hosting | free host | Free Web Space | BlueHost Review

FlyDragon by Robert Parker 2005

This java program can be run as an applet, in a window or in fullscreen accellerated mode. Don't dispair if the little applet above is not running. Read on.

The Windows XP I tried recently didn't have a Java run time enviroment. I downloaded this from the Sun web site. There are other sites for Java. I gather Microsoft has recommences shipping Java runtime with their OS.

A Linux run time Java is also available.

I think my Windows98SE came with a Java1.1 runtime as a plugin for InternetExplorer.


RUNNING APPLET

View the source for the attached flydragon.html.

Don't run two copies of the same applet. You will see multipul copies of the same dragonfly superimposed.

The internet explorer that came with Windows98SE appears to have runtime plugins for Java1.1 which will not run Java programs compiled for Java1.4. If your the applet is not running, trying using the flydragon1_1.html which calls flydragon1_1.jar.

The only feature not supported by the flydragon1_1 version (compiled using Java1.1) is that there is no full screen accelerated support.

If you are attempting to compile using Java1.1, substitute fullscreen-fake.java for the fullscreen.java. The fake file just holds an empty class to satisfy the compiler. I haven't set up any parameters to do auto configeration yet, so to see some action, press the mouse button in the upper section of the screen and select MANUAL, then AUTO, then FORNA and finally RELEASE. I'll explain the other controls below.

The code in the html file is:

"<"APPLET ARCHIVE=flydragon.jar CODE=flydragon.class WIDTH=640 HEIGHT=480">" alt="Your browser understands the <APPLET> tag but isn't running the applet for some reason." Your browser is completely ignoring the <APPLET> tag! "<"/APPLET">"

For the Java1.1 version, use archive flydragon1_1.jar instead.

Try out the Java 1.4 version hereFlyDragon

Try out the Java 1.1 version hereFlyDragon


RUNNING WINDOWED AND FULLSCREEN APPLICATION

Assuming you have a java runtime loaded then the application can be launched from a console (MS_DOS or LINUX) with the following lines. In each case JAVA_RUNTIME_BIN_PATH\ may be already in the systems PATH, so you could leave it out, otherwise, substitute the location in the PC where the runtime binarys are loaded.

For MS Windows with an accelerated video card and Java1.4 runtime:

JAVA_RUNTIME_BIN_PATH\java -jar flydragon.jar -fag

For MS Windows with no accelerated video card and Java1.4 runtime:

JAVA_RUNTIME_BIN_PATH\java -jar flydragon.jar -mg

For MS Windows with Java1.3 (which has no maximise option) runtime:

JAVA_RUNTIME_BIN_PATH\java -jar flydragon.ar -g For MS Windows with Java1.1 runtime: JAVA_RUNTIME_BIN_PATH\java flydragon -g

using the full directory of class files as Java1.1 has no -jar option for the java.exe. See the full list of class files below.

The same rules apply for Linux so for Java1.4 runtime:

JAVA_RUNTIME_BIN_PATH/java -jar flydragon.jar -mg

Supposedly Java1.5 will give Linux OpenGL support but I haven't tried it yet:

JAVA_RUNTIME_BIN_PATH/java -jar flydragon.jar -fag

Stable Debian Linux only seems to use Java1.1 but I got a Java.14 rpm installation to work.

I believe Java under Windows may be boosted by DirectX support. I'm not going to remove it just to find out.


FULLSCREEN MODE

Run as above with -fa options. It takes quite a while (30seconds) to come up on the Pentium 133, so don't panic.

To close the fullscreen application, click the mouse on the upper left corner. This will revert the program to the windowed mode.


USER CONTROLS

There are no key inputs. The mouse has 5 active areas when the left button is pressed:

If the MANUAL_MODE is selected, all these actions will apply to the animal which was closest to the center of the screen at time of selection.

If the AUTO_MODE is then selected, the animal becomes sentient again and the other actions will change the angle from which the camera views the animal. This has a further option AUTOPAN, where the camera will maintain an angle relative to the animal, but the view is a bit wild when the dragonfly is turning.

Selecting RELEASE will let all animals free. AUTO_MODE and RELEASE_MODE and FORNA are all pre-selected by the -g (GO) option when starting the program as an application (not yet available for applets).

If you return to FREE_MODE while the dragonfly is released you'll quikcly loose sight of it. In theory, if you can find a spot where there are no animals in view, selecting MANUAL MODE again will find the dragonfly for you (doesn't seem to work though).

The FORNA option creates a number of wild animals as set in the dragonfly.xyz file. Once you've got them you can't remove them. (YET)

Option DULL_GROUND will remove the water, sky, sun etc. It does leave the scenery (ie. water lillies). A slight speed improvement might be seen. BACKGROUND option returns the sky etc.

Option /10 will cycle through /10, /5, /2, x1, x2, x5, x10 time scalings. The program always starts with the dragonfly going at 1/10th normal speed. I am not sure if I fully impletmented this scheme.

PRINT_LIST sends a list of all current instances of objects created in dragonfly.xyz and by the forna process to the Java console. Under an application this will be the console from which you ran the program, but as an applet, you will need to select the show Java console option in your browser.

The EXIT option is obvious, but under FULLSCREEN this is replaced with WINDOWS. I found that the system exited better from FULLSCREEN mode if I returned to windowed mode first.

WARNING: In FULLSCREEN mode it is possible to crash the system if the threads get tangled.

COMPILING

Due to interclass dependancies, the java files need to be compiled in an order from base to main. Thus:

JAVA_SDK_BIN_PATH\javac [java file name including extension]

in the following order:

If compiling using the Java1.1 or 1.3 SDK, either don't compile the fullscreen.java (it will only crash if you use the -f option) or compile the fullscreen - fake.java version. Also, with flydragon.java, remove line 184, as MAXIMIZED_BOTH is not defined for 1.1 SDK.

You also need to have the directory "models" in the same place. This currently holds just one file called "dragonfly.xyz" which describes the dragonfly, blowfly, some colour information and some parameters for random forna.

You can then run the program with:

JAVA_SDK_BIN_PATH\java flydragon -[fagmr#]

where:

On a Pentium133, in a small window, 15 FPS is the best you can hope for. On a PIII 1.7GHz, 50FPS is not unreasonable. For some reason, on Linux, things are a bit slower and a Pentium400 crawled along at 6FPS. I think Java under windows may be using DirectX support, so you might need to have this loaded on your system. Requesting too high a frame rate can cause trouble with the multi threading.

To put it in a jar wrapper:

JAVA_SDK_BIN_PATH\jar -cmf wheretostart.txt flydragon.jar *.class

The wheretostart.txt is neede to run this as a jarred application but this will only work with 1.4SDK, so leave out the m and the wheretostart.txt for 1.1SDK, and only use the jar file in a call from a html file as indicated above.

Then run as indicated above under APPLICATIONS.


MODELS/DRAGONFLY.XYZ

Format is THINGNAME VARIABLES...


PLUG-INS

My initial purpose was to create a screen saver where other people could provide plugin animals and scenery. The description of animals would be added to dragonfly.xyz but their behaviour needs to be coded. Use drgnfly.java and blowfly.java as examples and then add your new class to zoo.java. I will add a description of the threads here if anyone is interested.


PROGRAM DESCRIPTION

I will do this when and if I port the program to GTK.


COPYING

Feel free to copy the jar files by downloading the following:

This program is realeased under a general GPL licence. See the source code by downloading SOURCE CODE. You will need to unjar it using:

JAVA_SDK_BIN_PATH\jar -xf source.jar.

Read COMPILING above to see what to do with it.

For those stuck with Java1.1 for what ever reason, here are the class files to be located in a single directory along with model/dragonfly.xyz


FUTURE

I, or someone else, needs to finnish the landclass psuedo random scenery generator so that the water lillies are not equally spaced. Some trees and rushes would be good too. I also want to create a new vertical object for thick tree trunks. Also fly behaviour is not very good and the dragonfly never gets to eat anything.

Why wouldn't DirectX or OpenGL wrappers be better for all this? Good question. The only advantage with using 2D Java for 3D objects is that older PCs can still run this program, if only slowly.

Seeing as I am now getting keen on GTK, I probably won't continuie with this Java version, but I may port it to GTK.

Have fun and send me any fixes to r dot p at webone dot com dot au.

May 2005

HISTORY

June 16th 2005 - I discovered that under Linux and XP it is more common to have two browser windows active at the same time with the result that if both have a copy of the flydragon applet running, the two threads get very tangled. Adding static to both thread definitions fixed this. Also I discovered that Java1.1 cannot run jar files as an application, so I've changed the instructions and added a list of class files for those who want them.


Opentimer Home