Thursday, 31 October 2013

Sky Is the Limit for Qt Games on Tizen

We had the opportunity to ask software engineer Thorbjørn Lindeijer to share his experience of using Qt for Tizen for developing Source of Tales, an online roleplaying video game. On Tizen smartphones it's an adaptation of earlier code to a full Qt Quick app and thus runs with true OpenGL hardware acceleration.





Qt for Tizen: What is the story behind this game?

Thorbjørn Lindeijer: The project started as Lurking Patrol Comrades, an entry for the Liberated Pixel Cup 2012. The content was developed from scratch while the client and server software were based on those available from the Mana project, which some of us are also involved in. The game features a large world, plenty of characters to speak to, both a melee and a magic based battle system and a polished user interface.

We ended up winning the Grand Prize of the Liberated Pixel Cup, which was a two-part competition: making a bunch of awesome free culture licensed artwork, and programming free software games that use it. Since then the project lives on as Source of Tales.

QfT: So this is an open source game? Cool! But why was the game ported to Qt?

Qt Quick 2 encourages a good separation between business logic and the user interface. It makes programming almost fun!
TL: Yes it is, you can grab the source from GitHub. The Qt-based client app started as a research project in 2010. I had been working for Trolltech/Nokia since 2007 so I knew Qt very well, and I thought the optimized rendering code in QGraphicsView would allow the game to run well on N900 smartphone. So far the Mana client was based on SDL and a host of other libraries. While this allowed the game to be easily ported to the N900, the result was quite unplayable on the small screen and playing it was not good for the battery life.

Physical Source Lines of Code (SLOC)
(without empty lines and comments)

C++12,187
Native GUI elements, resource manager, animated sprites and tile map QML items, QML items for communicating with the three separate services that make up the Mana game server
(src/ folder)
C4,535
The enet library (UDP network communication layer)
(src/ folder)
QML2,754
GUI, high-level glue between the C++ parts, and network communication
(example/qml/ folder)
JavaScript  0

Computation for C/C++ based on David A. Wheeler's SLOCCount.
Qt 4.7 was released a few months later and introduced Qt Quick 1, on which further development of the client was based because it made the UI so much easier to write. However, not much development happened on this new client in 2011 and 2012, until earlier this year the promise of the Qt Scene Graph and official Android support lured our development focus back to the Qt client.

When at the end of July we heard about the Tizen App Challenge and the Qt for Tizen port, three of us joined together with the intention of making the game fully playable with the new client before the
deadline. Since then it's been almost three months where we put in as much time as we could, and we got pretty far. I believe this is partly because of the way you develop with Qt Quick 2. Qt Quick 2 encourages a good separation between business logic and the user interface. It makes programming almost fun! Besides that, the rendering backend has proven more than capable for our game.



QfT: What devices are supported?

TL: The client app runs on Linux, Windows, OS X, Android and Tizen. For Android it's been running on the Galaxy S3, Nexus 4 and Nexus 7 (old and new). For Tizen I've been able to run it on a development device (the RD-PQ) thanks to the Linux Foundation and the Qt for Tizen project.

Qt really delivers on its cross-platform promise, so all we have to care about is the deployment phase. Each platform has its own rules for where to put the binary, the data files and included libraries, so the ugly part of portability is in the host of #ifdefs to look in the right place on each platform.



QfT: How hard it was to port this app to Tizen?

TL: Initial attempts were tricky because I did not have a Tizen development device. So, while I was able to get the client to compile with Qt for Tizen for the emulator, I had no idea how to turn it into a working package. Testing it was almost impossible since my PC does not support hardware accelerated emulation, making the emulator near to unusable.

Fortunately, Tomasz Olszak from the Qt for Tizen team was very helpful and set up the initial changes to the project to allow it to be packaged for Tizen. The changes were quite minimal and were mostly related to deployment and using the right paths to access the shipped data. Shortly afterwards I received a Tizen development device and could see Source of Tales running on Tizen for the first time!

The main problem we then ran into was that Qt for Tizen did not support the virtual keyboard yet. After the Qt for Tizen Alpha 4 release, Tomasz did an amazing job adding support for the virtual keyboard, making our game fully playable!

QfT: Do you submit to the Tizen App Challenge?

TL: We're currently trying to get the game through the validation process of the Tizen Store and will submit it to the Tizen App Challenge as soon as it passes validation. Initial issues have been about copyright, prohibited words, icon consistency but also more worryingly, "forced closing" of the application. We're waiting for more details to figure out what should be changed.

QfT: Please tell us about the future.

TL: The first thing we will want to do when the Tizen App Challenge is over is to release the game also on Google Play. This will allow a lot more people to try out the game.

Then, there are a lot of features that we had to cut because of lack of time. The server supports guilds, private chat, trading between players, etc. but the new client doesn't. Also, the SDL client has an advanced particle engine and can for example dynamically recolor sprites to add more variation. So for the future it will be interesting to look into supporting these things in the new client as well, without bloating the UI or making the game slow.

Another thing we would like to do is to make a variation of the UI that is more suitable for playing on a desktop. While it is possible to run this client on all desktop platforms supported by Qt, the UI in its current form is really only suitable for a touch screen.

Finally, we would like to extend the world with more content, more things to do. This is something we did not have time for during the Tizen App Challenge since we needed all the time we had for making the game playable.

And since we are a free software project, anybody who wants to join our efforts is more than welcome to do so!



Project's home page: www.sourceoftales.org

No comments:

Post a Comment