
It all started with the fact that I played a super-popular game called “Flappy bird”. Everybody knows her well and it makes no sense to describe the game. But I still have to say one thing: Flappy bird caught me with its simplicity of control and complexity of the gameplay. I could play it for hours on end and suddenly I thought - could it make the same exciting, yet easy to manage and concept game? It's easy, work for 2 weeks, I thought. And so it began.
About what? What is the game to do? These are the questions I asked myself for a few days. But later a very interesting and exciting moment came to mind in Valiant Hearts. In one scene of this game, the main character (soldier) fled under a hail of bombs and at a certain point he needed to stop in order not to fall under the explosion of shells.
So I came up with the gameplay and the concept for the game, and the name is simple -
Crazy Crazy . Now I had to start creating this masterpiece.
')
Graphics
For a long time I could not choose the desired graphic style for my game. Ran from one to another. But in the end I realized that this style must be simple in drawing (so as not to spend a lot of time creating textures) and special. I always loved a certain contrast of black, white and red, which was ideally suited for my game, so the choice fell on a style with these shades.
At first I tried to fill my main character with details to be remembered, but after looking at the heroes of other runners, the choice was made to simplify it. And in my opinion, it turned out only better.
The animation was done in the good old way, i.e. she was time-lapse. I don’t know how to do another, so I didn’t have much choice. There are only a few animations in the game: the hero's run, the hero's stop, the appearance of a bomb shadow, a bomb explosion. So I spent not much time on its creation.
But with the creation of the bomb, it turned out to be a little more interesting: first, I drew a fascist sign in the middle of its texture so that there was no emptiness there. But looking ahead, I will tell you that this was not the best solution. When setting age restrictions, both in the App Store and Google Play, this item is taken into account, since this symbolism is a sign of extremism in many countries.
Technical part
So I started writing the software part for my game.
Attempt # 1:I, as a naive little boy, decided that I could write a game from scratch using OpenGl, with which I already had previous experience (I wrote small games like a snake). But after 2 weeks of programming under Android, I realized the disadvantages of my choice:
1. It was necessary to write a lot of code from scratch, which would take a lot of time.
2. I would have to program the game again under ios, where I still need to know Swift / Objective-C. It would take more time.
Therefore, I realized that this scheme would not allow to finish the game by the beginning of summer, because of this I had to change tactics.
Attempt # 2:Now I finally realized that in order to quickly create a game for Android and iOS, I needed a cross-platform free framework with a small number of functions. And so my choice fell on LibGDX. It has simple and clear documentation and it works on both Android and iOS. Soon I came across a great article on Habré
"[LibGDX] Create a clone Flappy Bird - Zombie Bird" . Using it (thanks to the translator of the
eliotik article) in 10 days I was able to create a prototype of my game with textures and the main gameplay. There was no menu, no GameOver output and no music there. But I already liked my game. Easy to manage, but also a little hardcore in the gameplay.
Attempt # 3:It seems that I liked everything in the game and the code, but thanks to the comment from
1nt3g3r in that article, I realized that I did a lot of things wrong and ugly. There was no initial screen, during which textures were loaded in another thread, there was just a terrible game architecture and many other minor problems. I could not afford this, so I had to rewrite the game, based already on Western articles about libGDX.
But at the end of the development I had two main problems:
Support for various screen resolutions.
Stupid respawn bombs on the map.
Multi-screen support
As you know, on Android there is such a terrible and at the same time beautiful thing, like fragmentation. At first, I created the game only for my tablet (Nexus 7 2013), although I knew that I would have to add support for other screens in the game sooner or later. I thought to solve this problem this way: simply multiplying the width and height of textures by a certain coefficient, but unfortunately this did not help. On a tablet with a small resolution, it was displayed well, but on an old phone with a screen from the 90s, not really. Therefore, I divided the virtual world of the game into 2 main screens (or viewport), which are supported in libGDX:
StretchViewport is a screen that stretches to the full width and length of the real screen, without preserving the proportions. On it I placed the background texture of the game. Those. even on the iPad, even on my Nexus, the wallpaper was visible in full screen.
FillViewport - a screen that stretches to a certain size in accordance with its proportions. In this case, I made a virtual screen of size 800/450, i.e. the aspect ratio is 16 to 9. On it I placed all the remaining objects of the game world. Because of its special characteristics, it does not completely occupy the screen on some devices (for example, on Aipad), which is why such absurdity appears as the departure of bombs from the invisible border of this screen (see figure). But the gameplay on all devices is the same and the bombs fly on the iPhone for the same amount of time as on nexus 7.
Respawn Bombs
With the advent of bombs, things are not so straightforward. What is there with bombs? Yes, everything is simple: first a shadow appears, it increases and darkens, at the same time a bomb falls from the sky, and when it collides with the earth, an explosion forms and the shadow disappears. It is the explosion that kills the character.
Several times I reworked the algorithm for the appearance of bombs, but did not come to perfection. Now I will explain everything to you.
Let's start with how it actually works:
1. Find the random X coordinates of the bomb's new shadow in the virtual screen width (800 pixels) + 400 pixels.
2. Check the coordinates of the new bomb shadow to ensure that it is at a previously set minimum distance from other shadows (namely, shadows, and not bomb explosions).
3. If everything is good with verification, then a new shadow from the bomb appears, and after that an explosion.
Here is the actual code (forgive me, it is terrible):
private boolean checkCollision(float bombx, float minderuction){ boolean good=true; for(short i=0; i<bombs.size(); i++){ if(!bombs.get(i).getRocket().isHaveDamage()){ float curbombx = bombs.get(i).getShadow().getX(); int curbombwidth = (int)(bombs.get(i).getShadow().getWidth()); if(curbombx>bombx){ if(bombx+curbombwidth+minderuction >= curbombx){ good = false; break; } } else if(curbombx+curbombwidth+minderuction >= bombx){ good = false; break; } } } return good; } public boolean Generate(float minderuction, float minx){ boolean createbomb = false; if(getRandomInt(2)==0) if(bombs.size()<16){ float newbombx = getRandomFloat((float)(screenWidth+400)); if(newbombx > minx && checkCollision(newbombx, minderuction)){ CreateBomb(newbombx); createbomb = true; } } return createbomb; }
What is wrong? This algorithm is based on an unmanaged random. A player may be bored for 5 minutes due to the fact that the bombs do not prevent him from running through the playing field, and then die instantly due to two nearby bombs. According to the idea, you can increase the minimum distance between the bombs, but that's not so simple. This distance was calculated based on the length of the stopping distance of the main character, as well as its width. And because of its increase, the game may become too easy -> uninteresting.

Game release
So, the development of the game took me about 2 months (almost completed a couple of weeks). Now it's time to post the game on Google Play. Everything is very simple here: I registered with the developer on Google, filled out all the fields in the console, posted screenshots. Although I was surprised that because of the new age limit system, my rating in the United States has risen to 12+, but I have nothing to do here. After sending the application for processing and proceeded to release the game in the App Store.

As you know, for iOS development, you need a Mac. And I did not have it (and now no). So I had to get out. I learned that you can run a pirated version of OS X on a virtual machine in Windows. I did this for about a week. I could install the necessary version of this OS only from 7 times. Programs on it terribly braked, only XCode was downloaded and installed about 8 hours. But later, by setting up a virtual machine, I was able to squeeze a non-inhibiting picture out of it (and then the game with the framework compiled for about an hour and a half).
Now I had to connect the Game Center and AdMob ads to the iOS project. This was not particularly difficult, since I already had experience with the Android application.
I have some problems with debugging. It turned out that to test your game on the iPad (which a friend lent me to develop) you need to have developer status. I went to the Apple site, left the necessary application, sent my card details and after about 2 days my company withdrew money from it, and the key that they sent to activate the developer account was non-working. On this issue, I wrote to them about 5 times within 2 days, waiting for an answer. Only on the 3rd day, when I was about to finally spam their support, they sent me the working activation key from the developer account. The support itself answered only on the fourth day, but this is no longer important. (Now I am thinking that I should not have written so many appeals for support.)
The game was ready for iOS and now I had to release it. I made screenshots for different diagonal devices for the App Store using Photoshop, the description for the game helped me translate into English my friend. Finally the game was sent. At first I asked for an accelerated verification of the application from Apple, but they answered that they were already very busy, and I had to wait for the moderation of the game for 8 days.

That, in fact, was my first game for Android and iOS. I am very happy about this and hope you enjoyed my development history for these two great operating systems. If it is interesting to learn something else, I will be happy to answer all your questions, and maybe I will write a new post.
Thanks to Tibr for helping me write this article.