How I created my own 3D engine and game on it in 20 months
I wrote this article for your blog in October 2017.
It’s about the game Speebotwhich is now released on Steam. Free demo version is included.
I have been developing this game since January 2016 in my spare time alone. I did all the programming, gameplay design, graphics and music. Also, I wrote my own game engine from scratch.
People often ask me why I decided to create my own engine when there are many free universal engines available on the market. There are many reasons, and I will try to talk about them in this article.
One of the biggest advantages of a native engine is absolute code control. It is possible to configure it exactly as it is needed for a specific task. Such a highly specialized engine is optimized for a specific type of game and works faster and more reliably than a general-purpose engine.
Universal game engines are called so because they are intended for general use and they have features that not everyone needs. This inevitably leads to code bloat, and slower game performance.
The second advantage is the control of the development process itself. I believe that the toolkit should be as user-friendly as possible for the developer. What is convenient depends on the type of game in question. For example, for Speebot, this is a built-in level editor that allows you to quickly create new levels and immediately test them.
The decision to use my own engine allows me to integrate my own tools in a way that makes it easier and faster for me to create content.
Another big plus: you do not need to agree to the terms of a third-party engine license, sign contracts and pay interest on profits.
And finally: writing your own engine is very interesting.
Engine development began in January 2016. I called him YUME (“dream” in Japanese). It is written in Haxe, C++ and OpenGL. I am using a modified version of the library limewhich includes several useful features, such as allowing you to load resources and accessing OpenGL.
Prior to starting the engine, I knew next to nothing about 3D game development. It was necessary to understand OpenGL by reading documentation, forums and lessons intended for other languages (Java and C ++). After a couple of months, I had a pretty stable 3D renderer.
In addition to the 3D visualizer itself, many different systems had to be created from scratch: a 2D visualizer, a state machine, a time step system (more on that later), an interface system, a mouse, keyboard and joystick control system, dynamic shadows, a 3D sound system (using OpenAL), loading models (in a proprietary format based on IQM), “skeletal” animations, object hierarchy, real-time mirroring effect, text display, and so on.
In the end, we got a 3D library that can be used for something specific. Much of what I have listed is present in other engines, but YUME has a few differences. One of them is the time step system.
The time stepping system ensures that the engine processes and renders game frames at regular intervals. There is no frame per second limit in YUME, i.e. no attachment to 30 or 60 fps. The frame rate can be any, and the game will still run at the same speed, because the refresh rate of the logic is not related to the screen refresh rate. On computers of different capacities, there may be different performance, and the time for displaying one frame can be any. And the logic is always tied to 62.5 cycles per second (16 milliseconds per cycle). This is the basic principle of the time step system, although there are some edge cases.
As a result: on weaker computers, the frame rate per second decreases, but this does not affect the gameplay.
I had a ready library, but not yet an engine. It’s time to start developing the game and make decisions about the features you need. By that time I already had a few ideas and I knew I wanted to try experimenting with 3D “tiles”.
I started creating a game level system that used something similar to 2D tiles (tilemaps), but with one extra dimension. It turns out that the level can be added from the “cubes”, like a constructor. I created a map editor to speed up the level creation process. As a result, this editor got into the final version of the game and is available to every player.
The engine automatically determines which 3D model to use to display each tile based on adjacent tiles. I came up with a way to combine all the tiles into one common 3D model so that the video card does not have to draw each tile individually. The entire map is drawn in one go, which greatly improves performance.
Levels can be edited and tested immediately. For productivity – what you need.
I wrote a simple game physics system and started experimenting with gameplay. A few weeks later, the first prototype of the game was ready, in which the player could move the cylinder around the 3D level.
YUME continued to develop in parallel with the development of Speebot (around this time I chose this name for the game). Several problems with the engine architecture were found and fixed, several new features were added: physics, particles, reflections on the water surface, camera animation tools, interactive objects… Gradually the library evolved into a game engine.
I kept adding new gameplay elements, keeping the elements that I found interesting and getting rid of the excess. After some experimentation with the artistic direction of the game’s graphics, I created a character in Blender – a small robot with one wheel. The character is drawn and animated in a cartoon style.
At this time, I was already working mainly on the game itself, and not on the engine. I continued to create new levels, scenery, characters and elements of the game.
At the end of 2016, I took a break from game development and devoted several months to learning and practicing music writing. I have no musical education, but this is my hobby. I already had some experience in composing music for my previous game Hypnorain, but I wanted to improve my skills, so I immersed myself in studying music theory again. To compose music, I used the program sunvox, which is a virtual modular synthesizer. The final version of the Speebot game has a total of 23 tracks, which together make up over an hour of original music. I am satisfied with the result and will continue to improve my skills for the next game.
After that, I concentrated on creating new levels, adding new game elements, writing music and fixing bugs. I like this approach to game development. If I get bored doing the same thing, I switch to another activity, and therefore do not lose interest in developing the game.
After releasing several demos, processing feedback from players, and improving the game, Speebot was released in October 2017. The final version of the game has 200 levels, 4 worlds, a custom level editor, several additional game modes, and many other additional content.
The hardest part of developing the game was staying motivated and interested throughout the 20 months. I was able to work on the game only in the evenings after university and work, and on weekends. But still, it was very interesting.
I will continue to use and develop my YUME engine in my future games and have already started working on my next project.
After writing this article, I developed and released two more games on this engine: a story-driven adventure game Phantom Pathand a puzzle game Pilie Pals.