📜 ⬆️ ⬇️

How easy and natural to write a game in 2 years

In this publication, I will talk about my experience in developing a 2D game for Android, which lasted for 2 years and gained 15 downloads on Google Play. Also share some thoughts about the development.



Prehistory


One fine day, when Debian Linux was fun working on my machine, and I was plowing through the directory of configuration files, simultaneously destroying my nerve cells, and the idea came to me to rest. As befits the bad guys with poor eyesight, I decided to take a rest playing some game. As soon as I saw the screenshot of the Funny Boat game, I realized that I urgently need to make it a clone on Android.

Funny Boat Screenshot
image

Development


Almost immediately began the development of the game. As a game engine, I chose AndEngine (java language), which was still fashionable in those days, as I had some experience with it. The project received the technical name " Light Rabbit ". A week later I had the simplest prototype. I myself drew graphics and wrote code, and therefore the first results were scary. I also had problems with the display of water and waves, but this was solved in a day or two.
')
Prototype 01


The architecture of the game is based on the use of "scenes" (class Scene) and the tree structure of them. This is the most convenient means of delineating code in AndEngine. The scene is in its essence one of the tree's vertices, it has a parent and many descendants, there is a method in which you can add drawing of objects and event handling. As practice has shown, it is convenient to have a root scene to which all the main scenes of the application are connected. The root scene is a kind of manager and makes it easy to switch between scenes, taking into account the dependencies and features of individual scenes. It is from the root scene that all events (for example, tapping the screen) are sent to downstream "connected" scenes.

The hierarchy of scenes in the game


Actually, I had to stop at this, put everything in order, add a menu, get coins and a rating. But I did not stop.

Added a day and night shift (and the weather too!).





Added a system of units with primitive AI, strength and other characteristics. And a helicopter (and why not?). The mode of "friendly fire" for the unit was also regulated using the parameter of the world view (Neutrals, Pirates, Imperials, Allies, Enemies for all, and so on).





Added a dialog system. (And forgive me, Oleg Kuvaev for debugging icons)



The last points made me delay the lazy development for another year (!). I had to seriously change the architecture of the game, create my own command and script language based on the XML format. I even managed to release another game for this period.

Sample script snippet for the second level
<!DOCTYPE LRLevel> <Level> <Setting> <Chapter> </Chapter> <Name></Name> <Zone>SEA</Zone> <Weather>FAIR</Weather> <DialogBase>DialogBases/level_01.lrdb</DialogBase> <Fog colorR="20" colorG="20" colorB="20" colorA="255"/> </Setting> <Events> <Event command="SET_WATER_WAVE_HEIGHT" arg_int="30"/> <Event command="SET_WATER_WAVE_REPEATING" arg_int="20"/> <Event command="SET_TIME" arg_int="6"/> <Event command="STOP_TIME_IN" arg_int="21"/> <Event command="UNIT_ADD" id="0" arg_int="-600" arg_str="SteamShip" arg_str2="RIGHT"/> <Event command="UNIT_SET_PROJECTILES_COUNT" id="0" arg_int="32"/> <Event command="SET_DIE_POSITION" arg_int="-100"/> <Event command="UNIT_SET_POSITION" id="0" arg_int="200"/> <Event command="SET_FOG_VISIBLE" arg_int="0"/> <Event command="WAIT_SECONDS" arg_int="2"/> <Event command="SHOW_REPLIC" id="1" arg_int="2"/> ... 


Of course, for writing scripts in this form, an editor was needed, which was not at all. Attempts were made, but the scope of work grew to such an extent that I began to plan the release another year after 2.

Commands are read from the script file and then executed sequentially. I really wanted to add a conditional operator, but it did without it.

Agents


Simple sequences of commands were not enough, and then, I came up with such a thing as “agents”. The agent is created by the team, assigned to the unit and monitors the execution of any condition, while not delaying the main flow of command execution. After the condition is met, the agent performs the action and self-destructs.

I will give examples of agents:


Publication


After a considerable period of time, I got a little connected script, which spreads across as many as 11 different levels, including the tutor. I decided it was time to tie in with the development and start publishing.

Following the instructions of local residents, I made a publication on slide.me and w3bsit3-dns.com, and of course, on the google play market. Considering my analytics and the number of downloads displayed on slide.me (about 400 downloads), I conclude either about cheating or the impossibility of receiving data from users' phones. According to my data, from slide.me came less than 5 installations.

Stone in the garden w3bsit3-dns.com


After posting to the thematic thread of the w3bsit3-dns.com forum, my topic hung on day 2 on the first pages, after which it simply disappeared without any reason. However, this brought about 10 installations.

Analytics and embedded advertising


As a first experience, analytics and even a modest banner with advertising were built into the game. For the game developer on the AndEngine engine, embedding an ad is not an entirely trivial task, unlike, for example, Unity users.

Separately, I want to say how much I was amazed at the capabilities of tracking tools and analytics. With the presence of the Internet, it was possible to find out about pressing any button in the game, about how many levels passed, and who quit (friends complained about hardcore).

Once again, analytics is very useful even for small applications.

Mad Money


I managed to earn about 30 cents from the ad unit. Even the graphics will not bring.

By AndEngine


AndEngine is a great 2D game engine that gives you more freedom of action. You can easily extend it with your code, because it is open. There are a bunch of examples, you can connect Box2D physics or use shaders for graphics. There is a rather large community of people using it. However, it is felt that it began to become obsolete (deprecated is not uncommon), development is stopped (1.5 commits per year is not considered), and its fate in the coming years is an engine for familiarization and small games. I recommend not to linger and transfer to at least LibGDX, and maybe to something more high-level.

Source Code and Most Resources


This is my first completed project of this magnitude. It will not be updated anymore. Do not look for good code there, but some implementation points (for example, the water class for AndEngine) may be useful.

Link to the repository c code (Bitbucket) .
Feel free to click here - Google Play .

Conclusion


If you want your games to be played by a lot of people, make them simple, analyze the trends, do not rush into the development without a clear plan, hire an artist at last.

If you make a game for yourself - do what you want.

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


All Articles