Monday, July 13, 2015

Unity

A friend of mine and a game from the 2014 7DFPS jam, Discoverie, convinced me to try out Unity before going forward with C++/DirectX. Let's see what I can cook with it.

Sunday, July 12, 2015

Steps of a Single Threaded Game Engine.

As a first step in my game development travel I'm going to recreate a single threaded game engine. However this is only a first step, since it has been shown many times around that a game engine that does not want to be halted by stupid limitations has to be built up with concurrency in mind: I will start on it as soon as I understand how to do the simplest basic thing in Direct X.

I will initially follow the tutorials on DirectX Tutorial and on Riemer's Direct X tutorial.
I'm also a firm believer of the principle "if you learn something, you need to teach it again and help someone else", so when I will not write some code I will try to share back what I learned in a way (code) or another (notes), so if you see some terrible posts in this blog just shake your head and pass over to another post.

Single-threaded game engines share all a common architecture: they require some initialization (and a clean-up phase after you decide that the software ends) and are based around a loop.

In the initialization phase you set up, allocate, the memory for your calculation and load all the resources you need to show in the game.

When a scene starts you set up the game so that a player can play it. This is a bit different from the initialization phase (when you load assets) because here you prepare the world.

The Game Loop will see the following phases:

First you need to get input data from the input devices. You need to read signals from keyboard, mouse or joystick.

Then you calculate game logic, or better said "what happened during the last frame?" Did the player move? Did his bullet hit an enemy? A monster needs to follow some rules you set in the A.I.? Did you have to calculate some physics effect, like gravity?

Next you update the scene so that the engine can draw it.

At the end of the cycle you still have to check if the player decided to quit, or the game ended.
If the player did not quit (and the game continues) then the game loop restarts, otherwise you will need to go towards the scene teardown.

Teardown is the final phase, when you release directx resources and clean up memory before exiting the program.

A more complex game will maybe have different scene starting points, and delete some assets between levels, but generally, in a single threaded system, you will reuse the same game loop over and over.