There are lots of talented software developers in China. I saw some of them had written interesting games in JavaFX. As I introduced before, Liu Xuan wrote the Frozen Bubble game in JavaFX. Recently I read a post from blogger mqqqvpppm, who resides in a beautiful city Kun Ming in south western China. He did a good MineSweeper Game with JavaFX. Click on the below screenshot or the “launch” button to play.(JDK1.5 or 1.6U10+)

Here are the highlights of the source code:
The cells(Cell.fx) of the broad were implemented by extending the class CustomNode. The interesting part of the code is that four instances of Node are included in the CustomNode, which are used for four possible states of a cell: blank, a bomb, a red flag, or a number. One of the Nodes is visible at a time. The visibility of the nodes are bound to a few instance boolean variables. The main logic then controls these boolean variables to display different states of the cells. We can see the code making good use of JavaFX binding.
In the game, when a cell with a number is clicked, there is an action to uncover adjacent cells like flooding. This is another interesting part of the writing the game. mqqqvpppm implemented the code by indirect recursive functions.
In the current version of the game, a player may hit a mine on the first click. mqqqvpppm said he will modify this soon. Overall, I think the game is well written. Come take a look at the source code here(Note: mqqqvpppm has the copyright of this work), I am sure you will learn something from it.

There’s a small bug where you can hover the mouse pointer on the border between two cells, and both cells will be higlighted
Comment by K — May 30, 2009 @ 9:13 am