📜 ⬆️ ⬇️

Brave Octopus Adventure - the brave octopus is ready to conquer your Android smartphones


Hello. Not so long ago I had free time, which suddenly coincided with the time when I wanted to do something of my own, my dear.
And what can an ordinary programmer want to do? Of course the game !
Under the cut, my little story, which can hardly be called instructive or unusually fascinating, but nevertheless ...

It all started about a week ago. I had, in principle, a considerable programming experience as a whole and there was practically no experience in igrodel. About a year or two ago, I set myself Unity3D , in order to see what kind of beast it is, so the only familiar one was chosen from the development tools. Of course, it would still be possible to draw everything on the canvas, but, I decided that, perhaps, not worth it. From this initial acquaintance, I still have some memories about gameobjects, components, and what an orthographic camera can do to make a 2D game in Unity3D. As it turned out, in the current versions of the unit (starting with 4.3), there was support for 2D "out of the box", which I was overjoyed about. Now the process of creating a game object is reduced to dragging the sprite onto the stage. The sprite even scales under different screens, although I don’t know whether it does it in width, height or even in area (or maybe sqrt (area)?).
Here is a very scary and ugly initial sketch of the game screen.

Yes, it was conceived as a platformer in the style of the prehistoric Impossible Game .
IT was drawn in a fit of inspiration, when I suddenly decided that I could do anything. A man showed it to a couple, took off his rose-colored glasses and began to think. Since no development budget was allocated, my 12-year-old sister was determined to be an artist / designer.
Here is a redrawn example. I think it became better. And the fact that the graphics are childish, so games are made for children, right?

So, the development process began.

Big mistake times

I made the first mistake almost immediately when I thought about the level designer. After some reflection, it dawned on me that the unit itself was a wonderful designer. And after adding all the necessary objects to the scene in the right places, after the level was playable and tested, I ran it on my weak Nexus 5 and saw about 5-10 fps. It turned out that it was not a very good idea to add all approx 400 obstacle objects to the stage at once. So 2 scripts were written, one of which read all objects, their position and rotation angle from the stage and wrote everything into a text file, and the second later read this file and created objects on the fly when their time was right. Now at the same time there can be 50 objects and the nexus felt quite healthy, which could not be said about jiayu g2.

Big mistake two

It should be noted here, where did the development start. I started from the simplest in my opinion - from a dynamic background. Those. we have 2 sprites that follow each other, and when the one that is left out of sight, it shifts to the right and the endless conveyor of two sprites continues to move. And it was this that caused the subsequent gross error - I did not move the player relative to the background, but vice versa. Accordingly, when new objects began to appear, they also moved along with the background, and the player continued to rest along the X axis. And here you need to say thanks to this list of the 46 most frequently encountered errors. It turns out that you cannot move a collider (a component that tracks collisions) without a rigidbody (a component that is subject to all the laws of physics; well, or not quite all). Those. in its councils, this list even goes so far that if such objects are created from code, then you need to create them first, then move them where you need to, and only after that hang a collider on them. And I have all the obstacles in the game are colliders without rigidbody. And given that the background is moving relative to the player ... In general, I had to redo it. Now only the player and the camera are moving, and on jiayu g2 the game also works quite smoothly.
')
Not such a big mistake

There were also smaller blunders. For example, considering here is the location of the colliders:

Of which the lower one tracked the touch of the ground and everything was fine, and the upper one led to a quick and painful death, it was unacceptable for the player to slip through the obstacle and touch its upper collider. At the same time, there is an appropriate checkbox in the settings, which sets continuous detection, that is, it would seem, just what we need. But this only works with physics, if a player jumped and fell according to physical laws, and here this cannot be allowed, because In this case, sooner or later, displacements will appear during jumps and the player will fall when he does everything correctly.
As a result, 2 beams are now launched when they fall, such as these:

If one beam collides with the ground, and the second with a spike, then the touch to the ground counts. A finish, for example, is more important than land. So touch is calculated.

Sound

Thank you very much for the good music from fma , who spread it through creative commons.

Results

Fuh. Leisure time is coming to an end, I have some completed project (usually all beginnings stop somewhere in the middle). About unit, given the initial baggage of knowledge, I now know almost an infinite number of times more, but this is still very little. I still have the feeling that all this could have been done much simpler and more beautiful.
And here, in general, the game itself is tynts .

I almost forgot! In Android, since version 4.4, video from the screen via adb has become available. So I was able to concoct some video for 10 minutes in a video game maker.


PS To all who read up to this place many thanks!
It may seem to you that this is a small work for a few hours, but I spent a week of my time on it, and it was hardly such a standard work week, rather it was like the last day before the deadline. Everyday. Although no, most of all it looks like a hackathon a week long, in. In general, I went to nature, recover. Thank you all again for your attention, I spoke out.

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


All Articles