Have you ever thought about porting your iOS game to your BlackBerry PlayBook tablet? After porting my Pop Corny game, I want to share with you some details of this process.
The basics
Perhaps you, like me earlier, believe that the PlayBook has a certain relation to the technologies embedded in BlackBerry phones. I thought the same way, therefore I did not consider this tablet for a long time when transferring my games. In fact, the PlayBook is based on a new platform that RIM has created based on the QNX operating system. It will also be used in new smartphones on the BlackBerry 10 OS. Despite the fear that RIM, like Google, forces developers to use Java, and added support for native development tools much later, the reality turned out to be much better. The Canadian company offers a native development environment (NDK - Native Development Kit), which is a complete solution for creating software for your tablet. Unlike Android, for which NDK is an extension for the core development environment, supports minimal functionality and requires Java to be used in most cases, for PlayBok you can write native applications without looking at Java. NDK provides a full-fledged API for everything you need: from working with the screen and input tools to in-app purchases. ')
The development environment provided by RIM is called QNX Momentics and is based on Eclipse, however, if you wish, you can do everything with command line utilities. I chose Momentics even though I consider Eclipse slow and cumbersome, since it is convenient to develop in C / C ++ (it contains a debugger, profiler, etc.). In addition, I wanted to see how I was enough until the moment when I start to miss the command line. Surprisingly, for the first time since my acquaintance with Eclipse, I did not regret the chosen path.
And now we will look at the main aspects of transferring the game application from iOS to the PlayBook.
Data input
The processing of data entry in the PlayBook OS is very simple and, in accordance with the way iOS does, you should have no particular problems. Like any other event in the system, touch events are represented in the form of a bps_event_t structure, which you receive with bps_get_event (). This event belongs to the “screen area” and you request its data using the screen_get_event_property * () feature set.
int touch_state; int id; int position[2]; screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &touch_state); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &id); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, position);
The above code example is all you need to get basic information about touching the screen. The touch_state can be of several types: SCREEN_EVENT_MTOUCH_TOUCH, SCREEN_EVENT_MTOUCH_MOVE and SCREEN_EVENT_MTOUCH_RELEASE. They can be compared to the events of “the beginning of a touch / change of position / end of a touch” in iOS, however, it is worth noting the absence of the event “cancel”.
In addition, since you are polling the event, you receive it in the stream that you need and you will not have problems that I personally had when porting the game from iOS to Android.
Since the PlayBook lacks basic hardware keys, there is no need to process them.
Sound
As in iOS, the PlayBook OS supports OpenAL. If you use this open library for working with sound, you will not have to change anything in the process of transferring your program. The tablet OS also supports the ALUT (OpenAL Utility Kit) toolkit in case you need it.
Graphics
As you might expect, the PlayBook supports OpenGL ES (versions 1.1 and 2.0) without any problems. Included with the NDK comes an example of a simple application using OpenGL, which handles all the nuances regarding screen customization. Due to the simple but at the same time efficient API design, this example is self-sufficient and does not require more detailed consideration.
The tablet has a screen with a resolution of 1024x600 pixels and an aspect ratio of almost 16: 9, as a result of which it is narrower than the screen in the current iPhone and, of course, the iPad. Depending on your game, you will need to either remake the user interface for a given resolution, or add black bars along the edges. In the case of Pop Corny, it supports an aspect ratio of 1.33 to 1.50 with an interface that automatically adjusts to it. Therefore, for the PlayBook version, I added black bars, thereby reducing the aspect ratio from 1.7 to 1.50.
The number of pixels on the screen is roughly comparable to that of the iPhone 4 and iPad 2, so if you have graphic materials for these devices, you can use them for the PlayBook without any problems. If your game is optimized for the iPad 3 screen resolution, you will most likely have to reduce the size of the graphic elements in order not to waste the valuable memory of the user's tablet.
Content
Downloading content is never easier: no poking at Zip files, disabling compression, specific extensions, or asset management managers (hello, Android!). Applications are distributed as .bar-files, which in essence are zip-archives. During installation, the contents of the .bar file is unpacked and the application can access the file system in any POSIX-compliant way that you like.
If you want to download the files that were supplied in the .bar file (textures, sounds, etc.), you will find them in the following way:
./app/native/
If you want to create files and save your application data, put them in:
./data/
Easier does not happen.
Table of records and achievements
OpenFeint (a market called Gee) is not available for the PlayBook, the same goes for Apple’s Game Center, of course. RIM offers its own solution called Scoreloop , which supports player profiles, high score tables, achievements and fights.
In conclusion
For me, the PlayBook has become the easiest platform to which I have ever ported my development. I take off my hat to RIM engineers who brought out a POSIX-compatible platform that supports all the open frameworks so loved by developers. For most other platforms, you must add to your project all the libraries that your executable file needs. On the PlayBook, libpng, libjpeg, freetype and others are already included in the system and are ready to use. There are no problems with compiling, increasing the size of your executable file due to static linking with libraries that are already present in the system.
However, third-party PlayBook support is not as good as for other platforms. For example, to collect statistics in iOS, I use the excellent service flurry.com, which, however, is not "friendly" with the RIM tablet. This service provides support for BlackBerry through Java, but I don’t want to deal with this language at all.
You are not charged for publishing apps to AppWorld, unlike iOS and Android stores. At the end of the porting, you register, get the keys for a digital signature and publish your development. However, AppWorld applies certification programs in the manner of the Apple Store.
In conclusion, I want to note that the result was worth the effort. The porting process took me 2-3 days. I advise all independent developers to pay attention to this platform. It is also worth considering that the stores for iOS and Android are full of applications, so the PlayBook can be a good opportunity to get your game noticed. From the moment of publication until the writing of this article, Pop Corny for 4 days was in the list of the “News” section. If you are an independent developer, you know well how important it is that your product is visible to the buyer as long as possible.
PS Surprised PlayBook OS
I can't tell you how impressed I am with the RIM tablet. I believe that the platform, which allows a developer who has never dealt with it to port his own game in 2-3 days, has been done remarkably. However, what surprised me even more was the speed of the Pop Corny on the PlayBook, which was noticeably higher than on the iPad 2.
To confirm my words, I recorded a video with the launch of the game in parallel on two tablets. Since both versions of Pop Corny give out 60 frames per second, it is difficult to notice differences in the game process. It is worth considering that the tablets have approximately equal hardware capabilities (dual-core Cortex-A9 processor operating at 1 GHz) and the game was first released on iOS, and then ported to the PlayBook. But at the same time, the RIM device manages to start the game (download textures, unpack them and transfer the GPU, download sounds, etc.) 30% faster! I think this is an incredible achievement.