23 July, 2010

GHangtux 1.0

Wondering, what I have been doing the last few weeks?. GTK+ is the answer, GHangtux 1.0 the result, and since we all know that a picture is worth a thousand words I go just straight to the introductions: "World, this is GHangtux, GHangtux this is the world".

What is GHangtux?
GHangtux is a free program variation of the popular Hangman game. It has been designed for people of all ages and has a simple, easy-to-use interface.

It provides a keyboard and a sentence/word to guess, whose theme, the player is able to select. Current themes are: films, objects and persons.

During the game, a graphic sequence of tux images will be displayed, indicating the player how many attempts he/she has left. 

How to "create life" from some code lines?
1. Getting familiar with GTK+. As I wrote in the last post, I spent my first weeks at Openismus learning GTK+ and to put this into practice, I worked in a very small but helpful project. "Foundations of GTK+ Development" was very useful in this learning process and gave me a good base.

2. Making and correcting mistakes. The next step was to learn about all those mistakes I made, to repeat them and to relearn from them again. This is part of every single step actually.

3. Testing the new knowledge. After the first two steps, it seemed that I was prepare to start my first simple GTK+ application which is the very early version of the game.

4. Creating a custom widget. After playing with GTK+ a few more weeks, I decided to create my own custom widget: the game's keyboard. For this step, I found Davyd Madeley's clock widget tutorial quite handy.

5. Integration of the custom widget in the early version of GHangtux. This is the last version of the game. 

What is coming next?
- Internationalization with i18n.
- More themes.
- More image themes.
- Shortcuts for the menus. 
- Others: clutter, desktop files...

"Side effects" of having developed GHangtux?
- Learning Git and discovering how powerful this tool is.
- Learning Autotools helped by Alexandre Duret-Lutz's tutorial, and some    Openismus manuals.
- Practicing C.
- Practicing Glade.
- Programming style.
- Improving my communication skills.

You can follow the project under the repository in GitHub or download it in .tgz or .zip.  All comments are welcome, as are merge requests.



  1. Looks nice!

    http://github.com/Patriciasc/GHangTux/blob/master/src/main.c#L367 - shouldn't the path returned by get_system_file be freed somehwere? It's build via g_build_filename, but only freed if the the file *doesn't* exist.

    http://github.com/Patriciasc/GHangTux/blob/master/src/main.c#L463 - the code in every case looks very similar. could be moved to a function?

    http://github.com/Patriciasc/GHangTux/blob/master/src/main.c#L504 - not really random =) or at least not equi-distributed. consider a file with MIN_RANDOM + .5 * MAX_RANDOM entries - chances to get a non-exisiting entry on the first try is roughly 50%. In that case, the impl will rewind to the last entry. But perhaps I misunderstood the code.

    Anyway, it's less code than what I expected - well done, I guess ;-)

  2. Maybe you could create a sort-of library for providing a reutilizable code from GHangtux and create a Sugar version. This way you could learn more things :)