Creating games on Android from scratch - from idea to development

Has this ever happened to you: you look at passengers on public transport who are bursting balloons on their phones or are stuck in “2048”, and you think: “What a simple game! I want to do something like this too”? It happens to me all the time, so I decided to figure out how to create a popular game for smartphones. I found out what is the minimum you need to know to develop games, what mistakes to avoid and what to pay attention to.

Understand the basics

To understand how to develop a game concept, how to structure the gameplay and make it enjoyable for the user to play, you need to become familiar with game design. Books from The 20 Best Video Game Design Books will help you understand the principles of creating video games. Of course, you don't have to read everything.

In terms of programming, you need to be able to write native code for the platform for which the game is being developed. According to Alexey Rybakov, head of mobile development at DataArt, the following knowledge will be required:

  1. Understand the life cycle of an iOS/Android application inside the operating system - what happens at startup and a phone call, what resources are loaded into memory and when.
  2. Program in Swift/Objective-C for iOS and Java for Android.
  3. Understand sound and graphics (textures) formats for iOS/Android.
  4. Have experience programming in C/C++ for iOS/Android using OpenGL.
  5. Understand the game cycle from creation to appearance in the Store.

It makes sense to look at cross-platform gaming solutions:

  1. Unity 3D.
  2. Unreal Engine.

Game developer, co-founder of the FIFTYTWO studio, which released the JELLIES! (5 million installs on iOS) and Kenshō (“Editor's Choice” on the App Store and Google Play) Mikhail Shagin highlights Unity and C#: “Learn Unity and the C# programming language - it’s an industry standard. Working on this engine, you will develop quickly. For Unity there is an Asset Store - a store of ready-made solutions from developers. It will save you a lot of time and provide technology that was previously unavailable to small studios and novice programmers. Tutorials, video lessons and online schools will help you learn.”

Making a popular game, especially alone, is very difficult. You will need programming skills, knowledge in game design, 3D modeling, animation, and graphic design. Game development is the intersection of technology, art and business. Competence in psychology will also come in handy. Therefore, it is better to assemble a team.

“Modern games for smartphones on the market are the result of the work of well-coordinated teams, not just one person. Typically these are programmers, game designers, artists, musicians, testers, market analysts, advertising and promotion specialists, and financiers. Now it’s almost impossible to implement a popular game alone,” Alexey Rybakov shares his experience.

Kotlin

The language was officially introduced to the Android community in May 2017 at Google I/O. Already in 2020, Google recognized it as preferable for developing applications on Android, relegating Java to the background. This also means that the creation of new standard tools (libraries, Android Studio functions) will be primarily aimed at Kotlin.

Since 2020, Live Typing Android developers write exclusively in Kotlin. Projects such as Kinologik, Loyaka, LIME, Lawyer in Pocket, Kaspersky Security Pulse, Superbro and My Doctor are written in this language, and Sephora and ILE DE BEAUTE are gradually being translated into it.

Kotlin includes the best of modern programming languages ​​such as Java, Scala, TypeScript. The main advantages include automatic detection of data types, support for the functional paradigm, and extension functions. At the same time, the language received protection from a number of large-scale problems, for example, the “error in a billion”, or NULLPointerException. All this explains its popularity - according to a 2020 StackOverflow survey, Kotlin was among the top five most beloved languages ​​by the community.

Kotlin is based on Java, making the transition easier for experienced developers. If Java is unfamiliar to you, we recommend working with it first. Large projects with a lot of legacy code are most likely written in Java. That is, in the commercial development of applications for Android, tasks may arise where knowledge of Java will be required.

Gameplay comes first

First, develop the core gameplay - the basis of the game: figure out what the player will do, how and depending on what the game world will react to it. It must be addictive. Move on to the rest only when the core gameplay is 100% ready.

“Postpone fixing bugs, improving graphics, translations and voice acting until the final stage of the project. You will have to redo the game many times, and some of the work done late will be in vain,” advises Mikhail Shagin, co-founder of the FIFTYTWO studio.

The main criterion for cool gameplay is that it makes you return to the game. “The game needs to have depth so that the player stays in it for as long as possible. Ultimately, the success of games is based on the retention rate - the percentage of players returning over time,” explains Mikhail.

Game character

First create a new project and make sure the 2D option is selected.

Load your bird sprite into the scene. Don't forget to use your imagination!

Then adjust the size of the sprite as you like by dragging the corner in the direction you want. The sprite should be visible in the hierarchy window on the left. It shows all the objects in the scene, and at the moment there should be only two of them: the camera and the bird.

RuCode Festival

August 31 – October 4, Online, Free

tproger.ru

Events and courses on tproger.ru

Drag the camera onto the bird and release it. The camera should be under the bird, this will mean that the camera is now the “child” of the bird. Now the camera position will be fixed relative to the bird. If the bird moves forward, the camera does the same.

Select the bird again in the scene or hierarchy window. You'll see a list of options and attributes on the right in a window called Inspector. Here you can manage various variables associated with a specific object.

Now click on Add Component. Select Physics2D > Rigidbody2D - this is a ready-made set of instructions for applying gravity to our character. Click on Constraints in this panel and then select freeze rotation Z. This will prevent the bird and the camera from rotating in a circle.

In the same way, add a Polygon Collider that tells Unity where the character's boundaries are. Press Play and watch the sprite and camera fall down endlessly.

So far so good!

Now it’s time to start flying the character, fortunately it won’t be difficult.

First you need to create a C# script. Create a folder for it (right-click somewhere in assets and create a “Scripts” folder), right-click and select Create > C# Script.

Let's call it “Character”. Double click on it to open it in your IDE, be it MonoDevelop or Visual Studio. Then add the following code:

public class Character : MonoBehaviour { public Rigidbody2D rb; public float moveSpeed; public float flapHeight; // This is needed for initialization void Start () { rb = GetComponent(); } // Update is called once per frame void Update () { rb.velocity = new Vector2(moveSpeed, rb.velocity.y); if (Input.GetMouseButtonDown(0)) { rb.velocity = new Vector2(rb.velocity.x, flapHeight); } if (transform.position.y > 18 || transform.position.y < -19) { Death(); } } public void Death() { rb.velocity = Vector3.zero; transform.position = new Vector2(0, 0); } }

This code does two things. It makes the character move forward at a speed that we define in the inspector, and creates the feeling of a bird flying. The Update() method is called repeatedly throughout the game, so whatever you put here will be executed continuously. In this case we are adding a little speed to our object. The rb variable is the RigidBody2D script we applied to our object earlier, so when we write rb.velocity we are referring to the object's velocity.

A tap on the screen is interpreted by Unity as a mouse click if you are using a mobile device. After pressing, we force the character to rise up a little.

The moveSpeed ​​variable will be responsible for the movement speed, and the flapHeight variable will be responsible for increasing the bird’s flight altitude after each click. Since these variables are declared public, we will be able to change them outside the script.

The Death() method is also declared public, which means that other objects and scripts can call it. This method simply returns the character's position to the beginning. It will also be used every time the character flies too high or low. You will soon understand why it is declared as public. Line rb.velocity = Vector3.zero; is needed to remove momentum - we don’t want the character to fall faster and faster after each death?

Now you can exit the IDE and add the script as a component to the character. To do this, select our bird and click Add Component > Scripts > Character. Now we can define moveSpeed ​​and flapHeight in the inspector (that's what public variables are for). Let's assign the values ​​3 and 5 to the variables, respectively.

And one more thing: in the inspector you need to add a tag to the character. To do this, click where it says Tag: Untagged and then select Player from the drop-down list.

Try to apply the principle “Easy to learn, hard to master”

This is classic game design advice: learning to play should be very easy, but achieving perfection should be extremely difficult, almost impossible. This is what draws you to the game. “This principle is especially important for mobile free-to-play projects, because the developer has no more than 10 minutes to hook the player. Most users will delete the game after the first incomprehensible situation and will never launch the application again. A person must immediately understand how to play and what the goal is,” says Mikhail Shagin.

The authorship of this principle is attributed to Nolan Bushnell, the creator of Atari. In the original it sounded like this: “All the best games are easy to learn and difficult to master. They should reward the first quarter and the hundredth." Nolan Bushnell said this in 1971 in the context of Atari arcade machines. “Back then, slot machines were new, and the simplicity of the games was critical for the user. No one had any particular gaming experience, and for commercial success it was necessary for the player to have associations from real life,” explains Alexey Rybakov, head of mobile development at DataArt.

The prototype of the famous Atari game Pong was tennis. It is based on simple physical principles: the angle of incidence is equal to the angle of reflection and the like. It allowed real-life experience to be transferred to a computer game, so it was easy to understand for a beginning player in 1971. But as the ball accelerated when moving to a higher level, it became more and more difficult (hard to master) and forced you to play again and again.

Game designer Rob Prado came up with another variation of the principle: “Easy to learn and almost impossible to master.” Alexey Rybakov explains: “The idea is that it’s enough to simply collect the stuff necessary to get a new game item or level. Using StarCraft as an example, it’s easy to send all your troops and destroy the base. But as the player progresses through the story, new opportunities, objects, and units should appear. All this, plus interaction with real players, will lead to the fact that the game can be played in a huge number of options. The player will return to it many times.”

This principle is not a guarantee of success. But almost any decision that will force a person to return to the game is justified.

Lua (using Corona SDK)

A balance between the ease of learning mobile development for Android and the feeling of control on the part of the developer. The cross-platform graphics engine Corona is based on the Lua language. LUA is much simpler than Java, and the Corona SDK will make working with this language easy and enjoyable. It supports all native libraries, thereby allowing you to write for many platforms.

To write code, you need Notepad++, and to run it without first compiling, you need an emulator. If the APK is assembled and the program is ready for deployment, then you can launch the application through the online tool. With basic programming skills, you can master Android development using Corona without much difficulty.

There were some restrictions, and restrictions that made it impossible to develop serious things and establish yourself as a professional. If you need functionality in your application, such as in-app purchases, then you will have to pay for the opportunity to develop it, just like for using the native Android API.

Make gameplay simple and convenient

Think about the platform the game is being written for and the situations in which people will play it. Mikhail Shagin advises: “The gaming session will probably only last 10–15 minutes. It’s a big plus if the player can painlessly escape from the game. Step-by-step gameplay mechanics will help with this. The phone is usually held vertically in one hand - which means that you will only have one player finger at your disposal, the thumb. Build gameplay around simple swipes and taps - this principle is used in most casual hits. Look at Voodoo and Ketchapp, French game publishers whose installs account for 50% of arcade games on the App Store. Such projects are completed in one to two weeks, which does not prevent them from occupying the first positions in the top.”

Understand game promotion

Collections in app stores, advertising or word of mouth - what will work for your project? You need to understand what you are doing and for what purpose from a marketing point of view. Mikhail Shagin knew why the game needed beautiful design: “In Kenshō, we focused on quality and visual style, which brought us free support from platforms. We got on the App Store and Google Play and became “Game of the Day” in the App Store. Kenshō ended up in selections and banners, which gave us the bulk of our traffic.”

Python

Just because Android doesn't support using Python to create native apps doesn't mean it's not possible. Fans of this language have developed many tools that allow you to compile Python code to the required state, and the presence of various libraries will allow you to build even native interfaces in compliance with Material Design guidelines. The most popular framework is Kivy, which allows you to create a Play Market application in pure Python.

Rating
( 2 ratings, average 4.5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]