Day 9: Creating a Library Module

Today we finally start our engine’s Android library. After this day there will be a distinction between the game project we are working on and the game framework that powers it. If you are new to Android Studio, today will be specially interesting for you.

Starting a library

Projects and modules

If you are making a simple app, you will probably have a project with all the graphics, meta information, and code files that make up that app. It gets more complicated when you work on bigger solutions. Apart from your specific project, you might also need some external libraries which are not coded by you, or some additional apps to test your app. In other words you will be putting together a few individual projects to work together to achieve a bigger goal. This kind of modularity is addressed by modern IDEs. However, different IDEs handle it in different ways.

Project Structure in different IDEs

Continue reading

Day 8: The Texture Class

Based on what we learned about textures last day, we are now going to create a drawable texture object. Today the focus will be on coding. The difference between today and previous days is less of general knowledge, and more of a guide to the implementation of one of the classes in our engine. And unlike Stage, this class will be very close to the final version. Before we begin, I would like to express my best Christmas wishes for all!

Merry Christmas

Continue reading

Day 7: Textures

Up to now we can draw basic primitives. But these primitives cannot make a game if there are no pictures to complete them. Today we learn about textures and how they can help display images on our primitives.

What is a texture?

A texture is a 2D representation of the surface of an object. The object itself might be 2D or 3D. In order to understand what textures are, take a glance at the following figure.

Earth With and Without a Texture

Continue reading

Day 6: Drawing Primitives in OpenGL ES

In the previous day what we learned how to start a simple OpenGL ES project. Today we want to make it more interesting by actually drawing stuff. So, open project My Game in Android Studio and let us begin. If you do not know where to put code mentioned during this tutorial, don’t worry. I will provide downloadable source code for each day from this day forth.

Understanding primitives

Vertices, triangles, and primitives

You may find various objects in computer games with different shapes and characteristics. But regardless of how sophisticated objects are, they can all be described in the same way. In OpenGL ES (and in computer games in general), every object is defined by a series of “corners”. A triangle has 3 corners, a pentagon has 5 corners, and so on. One might argue that shapes like circles and spheres cannot be described in this way. The truth is that there are NO circles and spheres in a game world. In fact, there is nothing smooth. Even the smoothest spheres you may find in a game have corners, albeit many of them so they look smooth. As we are working in 2D, I give a 2D example to make this clear. Take a look at the following figure:

Corners of a Circle

Continue reading

Day 5: First OpenGL ES Project

Before we begin designing our stage, it is good to know how stuff works. Today we create a simple OpenGL ES app. I will try to design it in a way that we can easily conform it into our engine’s library. So buckle up and open Android Studio.

Setting up the environment

Creating the project

First we need to create a project. We target the latest version of Android, while keeping it still compatible with API Level 9 (Android 2.3 Gingerbread). Thus our app will be compatible with almost 99.5% of the devices in market. So, in case you have any doubts, make your New Project’s options look like the following (click to enlarge):

New Project Dialog

Continue reading