mastermindGraphics1A development of the program “Text based Mastermind”, This version uses a simple, more user friendly, graphical user interface. The coal with this program was to learn about making graphics in Java. This program uses almost the same code as “Text based Mastermind”, to run the game. But this program uses a graphical user interface instead. The user interface is now in English, but the comments are still in Swedish.

A “Graphics 2D” window is used to display the user interface. This window is animated in 10 frames per second. This window only displays the graphics, there are now clickable buttons on it. instead a keyboard listener is used to read input from the user. Every time the user presses a button on the keyboard a special function is called where the key is read.

This user interface was harder to make. But I think it is much more user friendly, and it looks nicer. But the user has to look at the description of the colors and press to corresponding number on the keyboard to make the input. Therefor this is not as good as it could be. The optimal user interface would be a combination of the clickable buttons in “Text based Mastermind” and the animated color graphics in this version. But I thought that would be to complicated for me at the time I made those programs.

mastermindGraphics2This version of the game also calculates a score that depends on the time it took for the user to guess the code, and the number of guesses that was used.

Download source code

Click here to download the source code.

I have used a free Java IDE called “jGRASP” to develop this program. The zip-folder only contain the source file. You need to compile it before you can run it.

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.