main banner

Development

Basic 2D Game development concepts

When I was in my last year of high school I didn’t know what I wanted to study. At that time I had a lot of free time and as a result, I was bored. Since I was a kid I’d been playing video games, so one day, when I was a teenager,  a great question came to me, how are video games made?

 

I started to research it and I found out that you can use something called a game engine or you can code them. I’d had a PC that I used for homework and gaming but I had no idea how software was built, so basically, I knew how to use PC and software and, for that reason, I chose game engine instead of learning programming because I read that programming was very hard. I found a free version of Game Maker and built a game where you could move a character. I didn’t have an idea about what kind of game I wanted to make, so I tried to add “nice” features that I didn’t know how to implement but that Youtube videos and Blogs were teaching. It was good until I realized that I was only able to “implement” features by following tutorials and that made me feel disappointed in myself. I decided to learn how things work and, as I was copying/pasting a lot of scripting code, to learn to program, when I looked back to see how I was doing I found myself loving programming, and that brought me to this point of my life (I studied Software Engineering). So, this blog (I’m expecting to create a series of blogs) is intended to provide a very basic path/concepts/how-to about 2D game development to everybody that is or was interested in.

 

Let’s begin with the most basic 2D game development concepts.

 

Tools

 

In the next paragraphs, I’ll show you different ways you can choose to make a video game. They’re very different and each one has its pros and cons to be considered before you start. The approach you take is up to you.

 

Game Engine

 

It’s a software developed mainly for fast game development (Game Engine, n.d.). Most modern engines include modules for different areas of it (level editors, assets management, particles editor, IA scripting, etc.).

 

Have you ever used Microsoft Paint? I’m sure you have. Paint lets the user pick a tool, a color, and start to draw directly. Game engines try to do the same, however, instead of drawing 2d images, they help the user to create games as fast as possible. Game developers do not have to take care of subsystems development but only need to use them to make their idea come to life.

 

There are some game engines out there, most of them are free (or have a free version),

can be used for 2D and 3D games, are multiplatform (develop your game for PCs, phones, consoles, etc.), and are well documented (by developers, community, and big game development companies!). Just to mention a few (Petty, n.d.): Unreal Engine, Unity, Godot, CryEngine.

 

Game Frameworks

 

It’s a collection of libraries for game development. They are used through a programming language which means you need to know how to code; usually, they include libraries for a few areas (rendering, collisions, particles, load music, textures, etc.).

 

If you’re thinking about developing a game for business I definitely wouldn’t suggest a game framework because they can consume a lot of time, and sometimes are not well documented. Also, keep in mind that not all frameworks support/document multiplatform capabilities. Anyway, if you’re on this for a hobby and like coding then this is your best option, you can use them to learn new programming languages happily!

 

You can find game frameworks for most of the programming languages that exist, so you can choose whatever language you prefer and look for a good one. Most of them are open source and have communities of considerable size. SFML (C++), SDL (C), LÖVE (LUA), LibGDX (Java), XNA (C#), and Phaser (JS) are examples of game frameworks.

 

Libraries

 

These are programming languages libraries used to achieve specific features (draw an image, play music, handle user input, networking, physics, etc.) in specific languages. They’re not developed for game development but any kind of software.

 

if you choose this way (the hard way in my opinion), you’ll need to write much more code for having a very small window drawing something. Sometimes they’re not well documented, or the documentation itself requires you to know a lot about low-level systems. OpenGL, OpenAL, XInput, Microsoft DirectX, are a few examples of libraries that can be used for game development.

 

 

Subsystems

 

I’d like to define subsystems as modules of games that can affect, either directly or indirectly, the gamer (end-user). Based on that definition, the following is a not-completed list of several subsystems used in games:

 

  • Rendering: It’s the process of generating graphics from a model (data structures can be used) (Rendering (Computer Graphics), n.d.).

  • Physics simulation: Used to simulate real-world physics in different degrees. Widely used by platform games.

  • Collision detection: Process of detecting two or more objects colliding (Lin, n.d.). This can be separated into 2 phases: Broad phase and narrow phase. 

  • Collision resolution: While detection determines if 2 or more objects are colliding or not, collision resolution is the process of moving the objects away from each other so they do not overlap as it’ll be weird for the gamer (have you ever seen a person fusioning with a wall?).

  • AI: Artificial Intelligence has been used in video games from the very beginning and its usage and implementation have evolved too. AI (in video games) is not always as sophisticated as it can be in other computing areas.

  • Particles: Simulates real-world particles to achieve graphic effects that otherwise will be hard to perform (Nystrom & Smith, n.d.). They’re widely used for explosions, smoke, liquids, fireworks, etc.

More specific concepts

The next list is a collection of concepts you’ll find while diving into 2d game development documentation, tutorials, etc.

  • Sprite: It’s an image that represents drawable objects in a video game for example the background. Usually, a sprite has an associated texture and can draw it either partially or completely.

  • Texture: An image that can be used by different sprites, sometimes are files that live on a drive (PNG is a texture format widely used in video games).

  • Game loop: The game loop is a programming loop that executes 3 main processes forever (or at least until the game ends): handle user input, update game objects, and render. More processes can be executed and the order can vary.

  • FPS: Frames per second is the number of times the processes inside the game loop run in a second. 24 fps are enough to get fluid animations but more modern games can run over 60 fps. They vary depending on computing performance as well as game optimization.

  • Shader: Shaders are small programs that run in a fixed step of the GPU pipeline and are used for post-processing video effects (Shader, n.d.). The type determines the moment when it’s run and what can be achieved with it.

  • Animation: It’s the change in a property of a drawable over time. For example, we can move a ball 3 pixels to the left every 1/60 of a second.

Conclusion

I know they’re a lot of new concepts, especially if you have never worked with game development before or something like that. Also, keep in mind that these are just a few; there are a lot more concepts to learn in your way to becoming a game developer.

 

Game development is not easy and coding is not everything, you will probably need to learn to use a drawing application, (simple) music production, just to mention a few other areas involved in game development. Talking about code, whichever path you choose of the 3 proposed in this blog, always remember to enjoy it.

 

A final piece of advice I’d like to share is that you do not need to be alone in this amazing journey. You can always look for a bunch of friends and get some fun in this weird hobby! 

 

References

Alberto C.

I come from a small town. I like video games, playing piano, learning new things, reading, food in general, anime, movies, exercising, and cars.

Articles