Mobile gaming today is a gigantic industry, where thousands of new projects appear every day. Many novice developers dream of creating their own hit that will be downloaded by millions of users around the world. However, the path from an idea to a implemented application on a device with a logo Android is full of technical nuances and requires a systematic approach.

Game development is fundamentally different from the creation of ordinary utilities or services. Performance, smooth animations, and resource optimization are critical here. If you are wondering how to write games for Android from scratch, you will have to master not only programming languages, but also the principles of graphics pipelines, physics and memory management of mobile devices.

In this article we will analyze the entire cycle of creating a gaming product: from choosing the right tool to publication in Google Play. We will not delve into the academic jungle of computer graphics, but will focus on practical steps that will help you launch your first working prototype in the shortest possible time.

Choosing a tool and game engine

The first decision you have to make is choosing an engine. Writing a game in โ€œpureโ€ code using only Android SDK and Java or Kotlin today makes sense only for the simplest 2D projects like quizzes or text quests. For everything else, there are specialized platforms.

The most popular solution in the industry is Unity. This engine supports the language C# and allows you to create both 2D and 3D projects with equal efficiency. The huge community and asset store make the barrier to entry as low as possible. You can find ready-made models, sounds and even entire character control systems, which significantly speeds up development.

The second most popular option is Unreal Engine. It uses a language C++ and a visual programming system Blueprints. Unreal Engine provides cinematic quality graphics out of the box, but requires more powerful hardware to develop and compile. For mobile devices it may be overkill if your goal is a simple casual game.

For hobbyists 2D graphics and minimalism are perfect Godot. This is a lightweight, open engine with its own language GDScript, which is syntactically very similar to Python. It consumes few resources and is ideal for indie developers working on weak laptops.

โš ๏ธ Attention: The choice of engine determines your future path. If you choose Unity, learning C# is a must. Switching to another engine in the middle of development will be extremely painful and time-consuming.

๐Ÿ“Š Which engine are you planning to use?
Unity
Unreal Engine
Godot
I write in pure code (Java/Kotlin)
I donโ€™t know yet

Setting up the development environment and emulation

After installing the engine, you will need an integrated development environment (IDE). For Unity, the de facto standard is Visual Studio or Visual Studio Code. For native development for Android, you will definitely need Android Studio, even if you use a third-party engine, since it is through this that the final assembly of the APK file takes place.

The critically important step is configuration Android SDK. During installation Android Studio you will be offered to download components: Platform Tools, Build Tools and system images for emulation. Make sure you download a version of the API that meets Google's current requirements. Currently, the minimum API level for new applications is often limited to version 21 or higher.

Testing the game on a real device is always preferable to an emulator. Emulators consume a huge amount of RAM and do not always correctly display the operation of the sensor or accelerometer. However, they are indispensable for quickly checking logic.

To connect the phone to a computer for debugging, you need to enable developer mode. Go to Settings โ†’ About phone and quickly click 7 times on the item Build number. After this, a new section will appear in the menu For developers, where you need to activate the item USB debugging.

โ˜‘๏ธ Preparing the workplace

Done: 0 / 5

Basics of game logic programming

The heart of any game is the game loop (Game Loop). Unlike regular apps that wait for user input, the game constantly updates the state of the world, recalculates physics, and redraws the frame. In Unity, this process is implemented through the Update() and FixedUpdate().

Method Update() methods, which are called every frame. Here the user input is processed and the visual part is updated. The method FixedUpdate() is called at a fixed time interval and is intended exclusively for calculations physics. Separation of these processes ensures that the behavior of objects will not depend on the frame rate (FPS).

Working with objects is based on a component approach. The entity in the game is a GameObject, which itself does nothing. It is given properties through components: MeshRenderer for display, Collider for collisions and custom scripts for logic. Understanding the hierarchy of objects and prefabs (object templates) is the key to effective development.

void Update() {

// Receiving input from the keyboard or touchscreen

float moveX = Input.GetAxis("Horizontal");

float moveY = Input.GetAxis("Vertical");

// Moving the character

transform.Translate(new Vector3(moveX, 0, moveY) speed Time.deltaTime);

}

Pay special attention to input processing. On PC you work with a keyboard and mouse, but on Android the main interface is multi-touch. You will have to implement virtual joysticks or a swipe system. Ready-made assets for mobile input can save you dozens of hours of work.

๐Ÿ’ก

Use Time.deltaTime when moving objects in the Update method. This ensures that the movement speed will be the same on devices with different FPS (for example, 30 and 60 frames per second).

Working with graphics, sound and optimization

Mobile devices have strict resource limitations. Unlike PC, there's no room for 4K textures in every corner of the screen. Graphics optimization is not the last stage, but a process that should accompany development from the very beginning.

Use texture atlases (Texture Atlases). This is a technique of combining many small images into one large picture. This reduces the number of draw calls (Draw Calls), which is a major performance factor on mobile GPUs. Also be sure to compress textures into the ASTC or ETC2format supported by Android video cards.

Sound in games is divided into music and sound effects (SFX). For background music, use compressed formats like Ogg Vorbis, and for short effects that are played frequently (gunshots, jumps), uncompressed WAV or PCMis better to avoid delays during decoding.

Parameter Recommendation for Low-End Recommendation for High-End
Texture resolution 512x512 or less 2048x2048
Polygons (per model) < 1,000 < 10,000
Shadows Disabled or baked Dynamic
Post effects Minimum Bloom, AA, DOF

Don't forget about the "garbage". In languages โ€‹โ€‹like C# or Java, creating new objects inside a game loop (for example, in a method Update) causes the garbage collector to run frequently (Garbage Collector). This causes micro-freezes. Use object pools (Object Pooling) for bullets, enemies and effects to reuse them rather than re-create them.

โš ๏ธ Note: Service interfaces and optimization requirements may change. Always check the latest performance recommendations in the official documentation of your engine before release.

Testing on real devices

The phrase โ€œeverything works on my computerโ€ is the main enemy of a mobile developer. The fragmentation of the Android ecosystem is amazing: thousands of models with different screens, processors (Snapdragon, MediaTek, Exynos) and OS versions.

You need to test the game on at least three types of devices: a weak budget smartphone (to check the minimum requirements), a mid-range device (the main audience) and a flagship (to check the maximum settings). Pay special attention to heat: if the phone overheats after 10 minutes of gaming, users will uninstall the application.

Use profiling tools. In Unity this is Profiler, in Android Studio - Android Profiler. They show the load on the CPU, GPU and memory consumption in real time. Look for memory leaks and heavy methods that slow down the main thread.

What is ADB and why do you need it?

ADB (Android Debug Bridge) is a universal command line tool that allows you to communicate with your device. With it, you can install applications, view system logs in real time (logcat) and take screenshots of the device screen directly from your computer. Command to view logs: adb logcat

Publishing on Google Play and monetization

When the game is ready, the publishing stage begins. You will need a Google Play Console developer account. Registration costs a one-time fee of $25. The moderation process can take from several days to a week, so factor this time into your release plan.

You need to prepare a store page: an icon (512x512), screenshots for different types of screens, a promotional video and a description. Texts must contain keywords (ASO) so that users can find your game in search. Do not copy descriptions from competitors - this may lead to a ban.

The issue of monetization is resolved before the release. Main models: paid download, in-game purchases (In-App Purchases) or advertising (AdMob, Unity Ads). For hybrid casual games, the most effective model is Free-to-Play with advertising and the ability to turn it off for money.

To enable advertising, you need to integrate the advertising network SDK into the project. This is done through the package import menu in the engine. Remember the rules: advertising should not appear unexpectedly during gameplay, only between levels or after the death of a character.

๐Ÿ’ก

A successful release depends not only on the quality of the code, but also on the correct design of the page in the store and the choice of a monetization model that is understandable to your audience.

Do you need to know mathematics to create games?

A basic understanding of vectors, matrices and trigonometry is necessary for 3D games and complex physics. For simple 2D projects, a school curriculum and an understanding of coordinate systems are sufficient. The engines take care of most of the calculations.

How long does it take to create the first game?

A simple clone of Arkanoid or Flappy Bird can be made in a weekend. A full-fledged project with unique graphics and levels will take a beginner from 3 to 6 months of constant work.

Is it possible to publish games without a computer?

Theoretically, there are development environments on tablets, but for serious work, compilation and debugging, a full-fledged PC or laptop with Windows/macOS/Linux is required.

Which is better: Java or Kotlin for Android?

Google officially supports Kotlin as a priority language. It is more concise and safer. However, a huge database of lessons and legacy code are written in Java, so knowing both languages is useful.