Some special notes when building a Game application on Android. Let’s not summarize first, it takes a lot of time. I go straight to the post.

I. Asset

Ok, we have 2 typical Asset types that are 2D and 3D

1. 2D Asset

To build a Game, almost everyone must use 2D images, regardless of the game genre from 2D to 3D. Well, construction games like fly-shooting can be drawn by their own code, but I’m sure it’ll look terrible when finished. Regarding this type of asset, we need to pay attention to the following 3 points:

Size

Each image frame should leave only the necessary and effective pixels. But unnecessary pixels should be trimmed as much as possible, because they will increase asset size and memory while running.

Data

When building a game, not all images are required to contain complete information about the image. Because each image format is different, the data stored in each pixel of the image is different.

For example, to reduce the number of colors on the image, many types of images do not need to be full of pixel information such as the background background of the image for example, we just need to focus on the characters with enemi, obstacle… is enough. With a background image that has opacity, in the image there is a detail that should be obvious, such as a house. Ok, you should separate that house from the wallpaper into a separate detail and set the image format accordingly. Regarding settings for images, they should be in 8-bit, 14-bit or 24-bit formats.

There are a number of tools available online that can be very helpful to you in optimizing your images. For example always 1 like http://optimizilla.com/ .😄

Image processing

Processing, uploading a lot of images or compressing a lot of images will also greatly affect the performance of the game. So creating alias or sprite sheets is also a good way to reduce image processing time.

2. 3D Asset

About this type is more complicated than the 2D type, there will be 2 big things to care about. =)) but don’t worry, you’ll get used to it after doing a lot.

2D Textures

This type will need to pay attention to optimize both 2D assets as mentioned above.

Vertices & Polygons

The rest of concern will be the number of vertices and polygons of the model. It is clear that all the polygons are linked together to create the details and shapes for the model. So the more polygons we get, the more details and sharper shapes we will get for the model.

BUT our problem here is that mobile devices are still limited in terms of hardware. Having to store information about points, polygon edges, rendering a model will consume quite a bit of memory. Therefore, limiting the number of vertices and polygons on the model helps you to increase performance a lot.

And yet, for each model there are many components such as a person. There are heads, legs, arms, body, .. so overlapping meshes can lead to a lot of redundant vertices and polygons. Therefore, when creating models, it is necessary to pay attention to a technique that is Rigging.

II. Use FULL all the features of external libraries

Nowadays game developers mostly use external libraries in addition to its convenience, just its availability. Saving the time. But parallel to it is that 3rd party libraries usually have a lot of things running in parallel that are actually not needed in the game. It will also affect the game more or less.

So one piece of advice is to carefully select and use libraries. If necessary, use it, otherwise limit it.

III. Doesn’t manage network connections at all

Oh move this, as my experience, there is still a lot. Many programmers don’t notice. Currently, most games on Android have a network connection, a lot of games are online. The frequent data transmission will take a lot of kb as well as very very battery. With realtime games, they often have a large number of requests and responses, not many developers want to save development time, so they don’t pay attention to managing and handling them properly, leading to many cases. game errors, holes, maintenance, repair more … so paying attention to the management of network connections is not less important.

IV. Rendering Pipeline

Still 2 types. 2D and 3D:

1. 2D EASY

Android’s 2D drawing system is based on canvas. All 2D assets are loaded onto the canvas for display on the screen. And they all have a defined position on the canvas. Although from android 2.3 onwards it is possible to use sprite 4096×4096, it can consume a large amount of memory. Many weak android devices will have difficulty loading assets of this size. That best limit size is 2048×2048. It should just be smaller, not bigger. This will save a lot of memory and draw calls.

2. 3D

Android uses OpenGl to render resources to the screen, so Rendering Pipeline for android 3D is the basic OpenGL pippeline. Whether the 3D game runs well or not depends a lot on the geometric vertices in the model.

V. Coding

Regarding programming standards for games, currently the component-oriented or modular style is still the best. The big engines tend to use this programming method, such as Unreal Engine, Unity 3D… In addition, it is also important to pay attention to programming skills that can make the game run like a horse or crawl like a turtle. For example, a programmer, when allocating memory but forgot to free it when not in use. :#) Just like that, the game may consume a lot of memory, also known as a memory leak =)). Then the result is freeze or crash.

The solution is nothing but learning hard. Well, there are some bugs that make the game poor quality that developers don’t pay much attention to, which are:

  • Create multiple static instances.
  • Repeat variable definition.
  • Not properly written.
  • Incorrect singleton creation.
  • Load objects while the game is running.

BECAUSE. Other

  • The choice to make any kind of game is also a matter to keep in mind. If making games with 3D processing, it must be accepted that it is heavier than games that only handle 2D. For 2D games, the FPS at about 60FPS is ok. As for 3D games, the range of 40FPS is also acceptable. The reason that 3D is heavier than 2D is because the 3D guy also has to handle the vertices, edges of the model, render Mesh, the 3D Collision system, the 3D Physic system…
  • Another problem is to pay attention to the differences of devices and game config to match the config of each machine. For example, some device components can affect game performance:
    • CPUs, they didn’t say in the past, but now most probably have speeds greater than 2GHz.
    • RAM: this is the component that has the biggest decision to the performance of the game.
    • GPU: Decide on rendering speed. It acts as a graphics processing element for the object.
    • Display quality: this guy is inversely proportional to performance. Because the higher the quality, the more RAM, GPU and CPU have to process. Fortunately, Android has already divided the display for each type (LDPI, HDPI, XHDPI, …).
    • Finally, there is the battery capacity. This guy is proportional to performance =))

OVER ! What else is missing, I hope you contribute more!