📜 ⬆️ ⬇️

Simple 2D races in space under Tizen or How to win hackathon Tizen Association

Friedcroc tizen hackathon

Last weekend in Moscow at Bersenevskaya Embankment, Lightbox Studio Red October hosted a hackathon organized by Intel, Samsung and FRUCT, dedicated to developing applications for the Tizen platform.

Our young (but very promising!) FriedCroc team took part in this wonderful event. And not just accepted, but also won first place! We decided to tell the community about it, share our experience and share the source code of our prototype.

Our project


Why 2D racing in space? Some time ago we posted a few games in the AppStore. One of them is dedicated to rabbits, who steal carrots from farm land. And since rabbits are not only valuable fur, they were safely launched into space to collect carrots there and evade asteroids. As a result, everyone is busy with his own business: Samsung launches Tizen for earthlings, and FriedCroc launches rabbits into space.
')
As befits any member of the hackathon, we had ambitious plans. We wanted to make a race with a rival, an upgrade of the rocket, pick-up boosts and other similar interesting things. We will, of course, make them before putting the toy in the Tizen Store, but there is no such thing in the prototype of this pleasure. We did not even have time to make sound effects, although we planned.

Tizen


Our acquaintance with the Tizen platform did not occur at the hackathon itself, but a week before it, at the final of the MDDay hackathon in Yakhroma, where we also participated (but, to our disappointment, we won nothing). The Tizen platform is still damp and far from perfect, and we had the pleasure of stepping on some rakes in Yakhroma. Fortunately, Samsung for each event sends great mentors who are ready to solve the problems of developers for days to fly. These guys do not give up until they find a solution, for which many thanks to them. But the problems were decent: we did not start the emulator, one of the test devices did not work (it had to be reflashed), there were difficulties in setting up the project. As a result, we spent about 4 hours to solve these problems. But to the hackathon in Red October, we have already come fully equipped.

So, with the platform, we were a little familiar. We also already had test devices (we got hold of them in Yakhroma, and absolutely free of charge: all that was needed was to sign an obligation not to sell these devices). It would seem, what else difficulties may arise?

Eclipse vs CLI


Tizen SDK uses Eclipse as a development environment. They explain this by the fact that for Eclipse it is easy to write plugins.

All FriedCroc programmers had experience working with Eclipse, and all of us, without exception, are sick of it. Basically - because of its buggy (which is only the "hanging" markers of syntax errors in files that are treated exclusively by restarting the environment).

That is why, when we learned that Tizen SDK has utilities for working with projects from the command line, we definitely decided to develop using these utilities. However, as it turned out, cantilever tools are quite raw. For example, the Makefile that these utilities generate requires the location of all source codes in one directory and does not support nested subdirectories. In addition, there is practically no documentation on this build method: it is not clear how to add compiler flags, how to specify a source directory, etc.

As a result, we still used Eclipse-projects: they support subdirectories, allow us to specify definitions and other compiler flags, and still know a lot of things that console utilities cannot.

C ++ 11


We write games in C ++. Moreover, we write games in C ++ 11. A fresh version of the language has a bunch of buns that reduce the amount of code and speed up development. Moreover, it is already 2014 and all the mainstream compilers have been pulled up at least to 80% of the support of this standard.

To our great disappointment, the Tizen SDK contains a very old version of GCC and libstdc ++ (4.5), so the normal support for C ++ 11 does not even smell there. For this reason, in Yakhroma we wrote our project in C ++ 98.

Naturally, we were not going to put up with this state of affairs, so we began to look for a way to build C ++ 11 code under Tizen. First, we are lucky that the Tizen SDK also includes a clang compiler. And although it is also very ancient, it still understands C ++ 11, even if it falls periodically into the crust. The problem of the lack of support for C ++ 11 at the library level (in the Tizen SDK, the old libstdc ++) we decided very simply: we took the fresh libc ++ source code from clang and put it in our project. After making minor edits and adding a couple of definitions to the project, libc ++ was safely assembled, for which we were extremely happy.

image

image

image

By the way, in order for the code to be built in C ++ 11 mode, the compiler needs to add the –std = c ++ 11 flag. Unfortunately, if you edit the list of compiler flags in Eclipse, it will be overwritten during the next build (Samsung engineers, take note!). As a result, I had to use the “Other optimization flags” field, which, in general, is intended for other purposes. But on the other hand, it is not overwritten during assembly and the flag reaches the compiler.

image

Enough about Tizen, let's talk about the project.


We used Box2D for physics. There is a debug draw in the project (which is disabled only in the release build). Do not be surprised that the ship has four "wheels" - we took as a basis some sample from the Internet, there were cars there.

Management is made very simple: the screen is divided vertically into three parts; pressing on the left side makes a turn to the left, on the right - to the right, and the central part is not used.

It is worth noting here that we really liked the idea implemented in Angry Birds Go when the machine “tries” to go in the right direction, even if the player does not control it. Therefore, in our toy ship also tries to follow the route, although not very successfully, if it does not help.

The picture we draw with the usual OpenGL ES 2.0. We are not even trying to discard invisible geometry (this is a hackathon, after all). Fortunately, the test device copes with this inefficient code and produces a playable FPS.

By the way, here are screenshots of what we did:

Screenshot 1Screenshot 2

With debug rendering:

Screenshot 3Screenshot 4

Level editor


The levels in the game are described by a simple XML file. In order not to write it by hand, in the framework of the hackathon we wrote a very simple level editor on Groovy. We will not publish its source code for now, but if suddenly you are very interested, write something, think of something.

Resource Files


We did not have time to deal with the mechanism of resources in Tizen. In order not to risk (time on the hackathon is very limited), we wrote a small tool that overtakes the resource files in C ++ arrays.

Sources


Game sources are available on github: github.com/friedcroc/tizen_spacerace under a very liberal license (MIT), so use. The code is hakatonovsky in places (a minimum of optimizations, a bunch of hard-coded parameters, and other such ugliness), but quite readable. Images are replaced by simplified black and white, do not be offended.

One more time about us


We are young, progressive, promising and just great! We really like to make games, which we successfully do. Sometimes we also do mobile apps.

If there is a desire to get acquainted with our games in the AppStore, links to them can be found on our website. And what is our site, I hope you can guess.

For this, let me leave, thank you all for your attention!

Source: https://habr.com/ru/post/217909/


All Articles