Archive for April, 2012
A few months ago I developed Urban Race, a very simple (and quite lame) time attack racing game using XNA. It was a University project so I couldn’t release the source until it was graded but then, I totally forgot about it. Recently, a reader asked me to publish the source and here we are. Please, bare in mind it’s for educational purposes, it was developed in one month without previous knowledge of neither C# or XNA and it’s not intended to be a fully playable product.
I usually document my projects with Doxygen and several articles or tutorials, this time has been different. At least I’ve uploaded a PDF file with the documentation I submitted for my project to be graded. You’ll have to excuse me for lack of further and more accessible documentation but I don’t have much time now and, prior to this moment, I didn’t think this game was worth making public.
Anyways, you can freely access the source, reuse components and re-share. Bare in mind that the code is under GPL v3 and the media is under Creative Commons 3.0 BY-NC so, please, stick to their conditions.
Edit: I just added UTF-8 support
Localization is a key aspect in games, specially if you want to reach a wider audience. I recently ported Freegemas to the libgdx platform and, as the original one, I wanted to ship it with multi-language support. There is no such a thing as gettext for Java and I didn’t see the Android internationalization system as a good fit in a multiplatform development. That’s why I developed my little own internationalization module.
Its usage is extremely simple, first we need a media/languages.xml file where all the strings in our project will be located. The syntax is pretty straight forward, we lay language sections identified with the code for each language. Inside every language, we provide a list of key value pairs with the localized strings.
< ?xml version="1.0" encoding="UTF-8"?> <languages> <!-- English --> <language name="en_UK" > <!-- Menu --> <string key="Timetrial mode" value="Timetrial mode" /> <string key="How to play" value="How to play" /> <string key="Exit" value="Exit" /> </language> <!-- Spanish --> <language name="es_ES" > <!-- Menu --> <string key="Timetrial mode" value="Contrarreloj" /> <string key="How to play" value="Ayuda" /> <string key="Exit" value="Salir" /> </language> </languages>
We can retrieve localized strings in our project through the LanguagesManager class and its getString() method. It’s been implemented using the Singleton design pattern as we only need one instance accessible from, potentially, everywhere in the code. When we ask our manager for a certain string we will use its key, if it finds it within the current language, it’ll return it, otherwise it’ll return the key itself. That’s why using strings in a base language (English) as keys can be a good idea, those will be returned by default.
For now, it uses lazy initialization which means it’ll load the language the first time the getInstance() method is called but that might change in the future. It automatically detects the system language (no matter if we are on Android or a desktop environment) and it fallsback to English if the system language is not among the available ones in the data/languages.xml file. However, you can explicitly specify the language you want to load through the loadLanguage() method.
LanguagesManager lang; lang = LanguagesManager.getInstance(); String option1 = lang.getString("Timetrial mode"); String option2 = lang.getString("How to play"); String option3 = lang.getString("Exit");
Freegemas libgdx is open source (GPL v3) as is this internationalization module which means you’re more than welcome to download it, use it and improve it. If you do the latest, make sure you distribute it the same way as me.
I can’t believe it’s been almost three months since I started at Crytek UK, time has passed amazingly fast! Nevertheless, I’ve managed to get some stuff done game development wise. I’ve always wanted to jump into mobile and that’s what I’ve been doing during the last couple of weeks. May I present you Freegemas libgdx edition!
It’s basically a libgdx port of the original Freegemas, a simple Bejeweled like C++ Gosu puzzle game developed by José Tomás Tocino who I have to thank for the neat original code and the excellent art. This means you can run it on your desktop, Android phone and very soon on your browser through HTML5 sweetness.
Libgdx it’s an open source Java library that allows you to create multiplatform games (desktop, Android, HTML5) sharing the same code base. That alone is amazing enough, so kudos to Mario for the titanic work. The library uses OpenGL so the performance it’s quite good even though we’re talking about Java! It has so many features and associated tools that it’d take me a few days to cover them all. Plus the community is always very helpful, besides the forums there’s always someone on the IRC channel willing to save your ass. However, to be honest it’s a bit of a downside to me it’s lack of UFT-8 font rendering support. Maybe some other day I’ll talk with some more insight about libgdx.
This was a warm up project, bigger things are yet to come!
PS: I must not forget about the HTML5 version of the game, it’ll be available soon.