computer science, programming and other ideas
To play sounds and music I use the audio part of SFML which is really good. It is a thin wrapper around OpenAL. It supports WAV, OGG/Vorbis and FLAC. Moreover, it also supports spatialization and it is really easy to use.
There are only two things for which an audio engine is needed.
The first one is to make sure that the total number of sounds and music never exceeds 256 (which is an internal limit according to SFML documentation). To do that, the audio engine refuses to play a new sound or music if the limit has already been reached. And as soon as a sound or a music finishes, it removes its instance to be able to play a new one.
The second thing is being able to pause all sounds and music, play other sounds and music and then be able to resume all the sounds and music that have been paused. This use case happens when you are in-game and some sounds or music are playing. Then you go to the pause menu, all the game simulation is paused, so the sounds and music should be paused too. Some sounds are played by the user interface in the pause menu. Finally, when the player returns to the game, the simulation resumes and all the sounds and music should be resumed too.
To achieve that, I will use two abstractions, one for each of the two issues, respectively the audio engine and the audio scene.
Let us dive into the details of these abstractions.
This week, I worked on the physics engine. It was the first time, I wrote a physics engine thus it took me a lot of time to design an algorithm that works well. In this article, I will try to share with you the issues I faced and then my current design of the physics engine.
In this article, I will share with you my implementation and my thoughts while designing it.
Firstly, I want to argue why I decided to implement a quadtree.
A Quadtree is a space partitioning data structure. Its main advantage against other data structures is its versatility. It offers good performance for insertion, removal and lookup. Thus, we can use it in a dynamic context where the data often change. Moreover, it is quite easy to understand and implement.
In my game, there are several places where using a quadtree is an instant win:
As you can notice, quadtrees are very versatile. They are a nice tool to have in your toolbox.
You can find all the code that I will show next on GitHub.
This week, I have worked on a light system. It will allow me to simulate a day-night cycle and to create a nice atmosphere during night or inside dungeons and caves.
This week, I have implemented a metric manager to easily report metrics. Then I have added features to my graphics engine. In particular, I have coded a wrapper around OpenGL and used it to finally render the procedural generated worlds in the game.