Perhaps the first game on Dart + Box2D

There are not too many articles on the Dart programming language on Habré, but there are a lot of articles on unfinished or hardly completed games, as well as how to make the latter out of the first. This article will be a mixture of these two topics.

This was the case: my old friend and I have been developing for several years. The game, which will be discussed in the article, is far from the first that we tried to make, but the first one with which it was possible. After almost a dozen failed attempts to make the game, we finally were able to objectively evaluate our strengths and decided to make a puzzle. The game genre itself is uncomplicated, but what we had in mind was much more complicated and unlike any of the games presented in the VK and FB catalogs in this genre. In order to have absolutely no chance to finish the game, we decided to use those technologies that have never been seen - Dart + Box2d.

Now about the impressions of the development on the dart. This is very different from developing in java / c # / php at least in that you cannot google the answer to a more or less complicated question, which at the same time makes you angry and gives you a pioneer feeling. Another significant difference in the dampness of technology in general, and tools in particular.

Dart language

I must say right away that the language was chosen due to strict typing and the classical approach to OOP. Probably, the language is most similar to Java, in general, the code of many methods can simply be inserted into java and they will work without problems, sometimes this trick can even work with an entire class. Of the differences, the key, in my opinion, is support for the procedural paradigm, which somewhat corrupts the code, sometimes allowing us to simplify the code for solving the problem. The next blow to safetyThe surprise was the lack of access modifiers for classes, methods, and fields. At first I resisted the temptation, but then such opportunities took their toll and as a result I got a very tightly coupled code that hardly anyone in this world would recognize as good, but this is hardly a language problem, but rather a lack of experience in general and its complete lack of respect for dart, especially at the very beginning of the journey.

Dart Editor (DE)

DE was made on the basis of Eclipse, which in itself does not make it bad, but it makes you wary. After using DE, it begins to seem like the corporation of goodness cut out all the nice features of Eclipse at the last moment. Fortunately, I found a plugin for my beloved PhpStorm, which is also damp, but here, at least in the IDE, you feel in your native land.

Dart pub

It is worth saying that in terms of packages Google really tried. There is a common catalog of packages, in one click you can get the desired library.

The Dartium binary expires after 12 weeks

An absolutely incredible feature of development in this wonderful language was that Dartium (Chromium with a virtual machine for dart) needs to be downloaded and installed again every 12 weeks, and if this is not done, then DartVM seemed to disappear, and what worked yesterday, instantly stopped working at all.


Box2d for Dart - I want to say right away that I’m working with this library for the first time and in the process of studying it there were several things that were very surprising, but over time it all settled down in my head, and it became clear that Box as a whole is just what you need, and the port is surprisingly good.


Dart2JS is a utility that comes with a dart development package for building dart code that is understandable only to a tiny handful of people in the universe, in js, which in the form in which it is obtained is not understood at all by anyone except the browser. Although, in fact, this is one of the pleasant moments of development, although in order to build the project, the first time I had to kill a fair amount of time. It should be noted that so far have not met a single bug related to the incorrect construction of JS. code. By the way, it turns out, as one would expect, to be completely unreadable.

Dart & js

Of course, using dart, sometimes there is a desire or / and the need to use JS code, there generally a good toolkit is provided for this, but it is impossible to use it. Now I will try to explain. This is the best library that could be for working with JS, but for a language so related to JS, I think this support should have been transferred to the language level, the syntax could be something like using asm from C

Now it looks in the best the case is something like this:

      static void getUser(Function callback) {
        (context['Features'] as JsObject).callMethod('getUser', [new JsFunction.withThis((JsObject obj) {

Dart & External Api

I was always in love with the VK API, it seemed to me and still seems to be an example of a correctly implemented API for a web service. Among other things, VK also provides a js library for convenient access to its API. While developing other applications for social networks, I always liked to use this library, but when I had to access it from a dart, it turned a fairy tale into a nightmare, so I tried to hide it in the farthest class of my project and open it less often. The thing is that, as I said, working with JS in a darth is implemented as a library and requires constant manipulation of objects, i.e. the lion's share of the time for wrapping dart objects in JsObject and picking out from the other JsObject the few data I need for which it was all up to. But after much torment, I was able to reduce the common ground of languages ​​to a minimum,

Two cubes

Game development took much more time than we would like, as it often happens. In any case, this is the first game that finally managed to finish. The main problem of its delivery to the masses is likely to be that it turned out to be rather complicated, not even in terms of management, but just like a puzzle. For example, out of the 2,000 people who are now playing it, having spent almost 15,000 attempts, only a dozen people have completed both chapters, although maybe this is the right percentage?


UPD: Link for those who want to see what happened in the end:
UPD 2019: On social networks, the game was deleted for a long time because we forgot about it for a long time, but recently there was a time and a desire to resurrect it, at least so that she spins somewhere and warms the soul. Now available on

Also popular now: