Slow Start
The morning was a slow start again. I’m don’t know why it happened but I just couldn’t get myself to work. While I didn’t even force myself to work on car physics even. I just had to look into how to store entities to disk. An exciting thing to work on if you would ask me. But still I couldn’t get my hands to start typing or anything.

Sparse Entity System
At one moment I managed to finally got myself to work though. I looked at the code for the entities and thought about the changes Casey of Handmade Hero made. So I looked at the videos where he changed the entity system. I did understand the theory behind it better this time. However I was hesitant to go his route and decided to go my own route.

Though that didn’t last long. The hesitation wasn’t gone, but packing the entities into the tile chunks was just too interesting. So in the end I decided to follow the three videos. I haven’t finished the last one, but the changes are almost done. And it does feel like nice to not have two entity types anymore, but just one. There is definitely some other stuff I can clean up later. But for now I just have to finish the video and get everything working as before.

I did do some cleanup of the entity types, as in the Player and Wall types. So now there is only a Car type and Prop type. Props are just trees and houses etc. Removed some redundant test code as well. It felt nice to go through the code like that. As well as move some functionality out of the level code into its own function. This way it’s way easier to read what is happening during the update and render of a level.

I am still wondering if the UpdateAndRender-functions need to be split up. But maybe just storing a bit more or different info in the rendering buffer is enough to implement proper stereoscopic 3D rendering later on. I can’t wait to try some parallaxing things at the end of the year. Still a long while of course, but I think it can be such a nice effect!

As you can see below not all entities are back as well as the tiles. Actually the game crashes at this screen after a second haha.

So we finished the third video about the entity system. Which basically completes it. Though for us it’s not working yet. We still have tiles in our chunk. They are called tile chunks after all.

However they basically create memory leaks right now. Since the chunks get removed and re-added every frame. So we should not only unpack and repack the entities. The same should happen for the tiles array.

I will have to think about a good solution for it. As we may have multiple chunks active at once, so just storing one pointer to the array is not possible.

Last modified: June 5, 2023