A long time ago I had written a simple Java game applet with regular JavaSE and Java 2D. It was nothing fancy just something I had wanted to experiment with. I have long since lost the source code and never got around to making the game *pretty* including the introduction of game levels etc..
With a little time on my hands and looking for a fun introduction to JavaFX, I rewrote the game in JavaFX. I was also curious to find out how much easier writing the game would be using the graphic oriented JavaFX script language.
This tutorial is meant for readers with no or little prior JavaFX experience and no or little experience writting games. For an advanced tutorial on how to write a game in JavaFX please check out this article on Inside RIA
So here goes…
Installing Netbeans
As of now your best option of developing JavaFX seems to be with Netbeans. As of now 6.7.1 is the latest release with JavaFX support. Installation is pretty straight forward and simple Google search should get you any help in case you need it.
The game (as of now)
This is a short discription of the game’s rules.
You are in control of a character (currently a somewhat boring square).
You must:
- always be on the move, otherwise you loose points
- avoid hitting the other characters (currently somewhat boring circles), otherwise you are dead
- touch and stay on one of the circles if it changes its color from red to green (not touching it at least once will make you loose points)
So the rules are simple enough and all other ideas and improvements will be added once the basic gameplay has been achieved. Below should be the original version of the game:
Original Game Applet (click on applet for focus and press space bar to restart)
Now you know what the game looks. like in the next entry we will start programming
[...] A multi-part blog on Creating a Simple Game in JavaFX [...]