Bricks3 – Jewel Quest in Java

Today I wanted to show you one of my two largest projects – my own implementation of jewel quest game. I have been working on it September and October 2010. Game doesn’t use any engine and is made using Swing only.

It was nothing professional, today I have seen that it has poor documentation, but it was a great fun and I have learnt quite a lot. The source has over 3500 lines of code and with graphics and sounds has over 4MB – link at the bottom of the post.

  • Previous versions and techniques used:

Probably you will ask why it is Bricks3 and why not just Bricks or maybe Bricks65? Well, that’s because it’s really third version of this game I have created. First version had started as a one-evening-project and had about few hundred lines. It contained only necessary algorithms for board modification and the GUI in Swing with no animations and timer. Also there were no sound or graphics (except Swing one). I tried to use additional threads to modify positions of objects in Swing, but at this point I didn’t know much about concurrency in Swing, I heard that there exists something called event dispatch thread and didn’t know about SwingWorker class. So I started looking for suggestions how to easily create simple animation in Java and have found drawing on 2d graphics. And it was the second version. Algorithms very copy-pasted from first version. The problem was that drawing on 2d graphics was quite time consuming and even on fast computer it was impossible to obtain satisfying frame rate. Third version I have implemented after I learnt a lot about Swing and how does the event dispatch thread works.

  • Serious bug remaining:

Unfortunately, there is still a bug concerning SwingWorker threads. I have used thee SwingWorker threads, one is working all the time to modify a timer, the second one is responsible from swapping adjacent bricks and the third one is responsible for moving the bricks down. The strange thing about it is that in some java updates everything works, in others it doesn’t (e.g. in two recent updates 25 and 26). SwingWorker thread should now be invoked by other SwingWorker thread – in this case, third SwingWorker is invoked from second SwingWorker’s done() method. But if it was a problem, removing first SwingWorker thread responsible for timer wouldn’t fix the problem. For now I can say that I would rather create a game using a game engine instead of debugging and extending this. I have also spot that this bug occurs now (java 6 update 26) only while running the code from netbeans, jar works fine…

  • How did it finish, what is still missing and what I have learnt:

I gave up a project in the late October 2010 as it stopped being so interesting for me. Also I have encountered problems with managing a lot of code – it was a good lesson how important careful planning and design are. Project’s todo list remained quite long. The most annoying missing feature is possibility of playing in window. Game automatically turns full screen and uses 800×600 resolution – it’s really annoying when you’re using two screens… Also a real sound was never implemented.

  • How does it work:

As in most of such games, there is no particular aim. You have to survive as long as you can – there is a timer, you receive additional time for all bricks vanished and the time added is getting smaller with your progress. When a brick vanishes, it recovers a piece of background image. Once entire image is uncovered you advance to the next level (that’s when it’s getting harder). There is a pause button (also space works). The game is saved after each move so you will never lose too much of your progress. Save is deleted when game is over. Since version 1.2 there are some debugging tools commonly called “cheats” ;) There is also list of highest scores.

  • Download:
  1. source
  2. jar file – full screen, timer on
  3. jar file – window mode, timer on
  4. jar file – window mode, timer off (see a bug description above)
  • Screenshots:

This slideshow requires JavaScript.

  • Patchnotes:

– it is no longer possible to use “pause” and “menu” buttons after game is over
– algorithm checking possible moves now does not ignore bottom and right board’s edges
– “No more moves” sign is shown before recreating entire board
– special bricks added
– gray brick is darker now to make it more different from pink one
– number of colors in game is now increasing correctly every 5 levels

– save and load added – game is saved automatically after each move
– keyboard shortcuts in both menu and game added
– debugging tools added: custom mode, special bricks chooser, color changer, time controler
– new background is loaded after bricks fall, also level and difficulty are increased with some lag
– maximum time decreases with new levels
– chance that new brick will be special has been decreased
– application uses now a bit less memory

– game was not saved when there was no directory Bricks3 in Bricks3.jar’s directory – this has been fixed

  • About graphics:

Most of the photos used as background are from Mark Vincent Müller collection. Others found on: and Main menu graphics has been created by me in CorelDRAW, in-game graphics is pure Swing (more precisely – borders).

About Jaroslaw Pawlak

I have done MSci in Computer Science at King’s College London and currently work as Software Engineer specialising in Java. I spend most of my time in front of computer improving my programming (and other) skills or just relaxing with a good game. I also train some sports but at the moment I am not a member of any club. I love cycling and volleyball, but I have also played a lot of football, tennis and trained martial arts.

Posted on June 26, 2011, in My Projects. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: