Macca Blog

My life experiences with code and design

Space Mission FX

Posted on by Mark

For a small while now I have been playing with the preview release of JavaFX and have been quite happy with it. There have been the few bugs here and there and the netbeans plugin still has some ways to go, but hey, its a preview release, its allowed to!

I decided that I would really take some of my many many many small sample apps and make something useful/fun out of them. Some of the samples included basic key handling, interpolation/animation, binding examples, etc… you get the point, mostly different JavaFX techniques.

The results is “Space Mission FX“, a port of the classic Asteroids retro game from the 80′s.

The currently version at the original time of this posting is a stable version with no real “target” for the player, rather, just some fun shooting up some asteroids, and trying not to get killed. I certainly plan to continually grow the game over the next short while, and also re-implement it when the v1.0 SDK is released.

Also, I will be making the source available on request, and if enough people are interested, I will make it available to anyone.

This blog entry will contain dated updates, when I make them, to let you all know what exactly the latest version contains and bug fixes etc…

Introduction
The game puts you “the player” in a space ship (white triangle) in the middle of the screen and randomly places Asteroids around you that move in random directions at random speeds. You navigate with the arrow keys and shoot with the space bar.

Screen Shot

As you can see, it is a pretty basic port of the classic game Asteroids

Development
I found developing this game to be very simple, in regards to JavaFX. The only real difficulty I had was with the actual mathematics involved, which I don’t have that much experience with.

I was surprised just how much things just seemed to work using JavaFX, animations/movement, data bindings, OOP design principals, etc… and constantly adding new small features was never much more than a few tweaks and the odd new class.

Main
The game has the typical Main.FX file which handles the initiation of the game, creation of the asteroids, spaceship, stars as well as the main collision detection timeline that handles the intersections of the on screen objects.

Game Elements
As you can imagine, I used basic OO design principals here to create each game entity. One class per entity, custom properties, etc… they sort of handle themselves in regards to movement and lifetime.

The game elements are as follows:

SpaceShip
Rocket
Asteroid
Star
Explosion
Particle

And some other misc displays and helper classes. Pretty simple huh?

Updates:
19th November 20o8
Initial release of the game to the world…enjoy!

28th November 2008
* Added new scoring and level based displays to the game and cleaned up some of the code as well to help with performance.
* Added new webstart link, see below for instant Space Mission FX enjoyment.

Source Code:
The source code can be made upon request, and if enough people are interested, I will just make it generally downloadable.

Source Disclaimer:
I have been messing around with this for a few weeks now and make no claims that it is implemented the best way. Its simply one way of doing it. I am always open to suggestions, tips, ideas etc… just leave a comment.
You may also find random, unused variables, methods, etc as well for the above reason.

I also have only tried to run this version on Windows XP SP2 so far.

More Screen Shots:

Getting it running:
You must have the minimum requirement for running a JavaFX application, which is making sure that you have Java 6 update 10 installed on your PC. Here is a link to the download page.

Download the distribution here: (hosted on box.net)
http://www.box.net/shared/pqadqmsgk0

Extract the RAR file, and then you run the command:
java -jar “SpaceMissionFX.jar” spacemissionfx.Main

New*Webstart download
You can now download the latest version of the SpaceMissionFX from here and be playing in no time!

Help I had/have
Any Java developer knows that the Java community is very large and very helpful, I have had a great deal of support from the following sites:

Java.NET Forums
Stackoverflow
Sun Forums

Thanks
I love feedback, so if anyone has any suggestions, ideas, bugs, etc… please post a comment.

This entry was posted in games programming, Java, JavaFX, SpaceMissionFX. Bookmark the permalink.

2 Responses to Space Mission FX

  1. StenKarl

    Hey Mark, it looks like you’ve got some cool JavaFX stuff going here — I’m impressed.

    Any chance you could webstart or applet-ize some of these?

  2. Mark

    Hi StenKarl, thanks, it was a lot of fun getting them going too.

    I am currently working on a webstart version of all of them as we speak! I hope to get them going as soon as possible.

Leave a Comment

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>