GameDev 2019 Week 3: Entites & Projectiles
Mobs can be shot now!19.01.2019 - 21:58
On the weekend I made a few changes to the blogging software including email notifications and the ability to include youtube videos, which I needed for last weeks blog post and I didn't finish the blog post of week 2 on the weekend so I had to finish it today... yay, week 2 and already behind ^.^
It was a very productive day, I implemented most of the entity system for the game. Entites can now spawn, follow their path through the maze, take damage and they will also rotate towards the direction they are walking in. And they can also be deleted, this wasn't actually as easy as it sounds because the game cannot simply delete an entity, other classes or at least the entity renderer may still reference the entity when it dies in the game logic and deleting the class would cause a lot of undefined behavior and crashes. Therefore I mark the entity as dead, but still keep it in memory for a few ticks so everything else that references it can react properly and only then delete it completely. On the rendering side the entity system is implemented, however they are only rendered as a box at the moment, my animated model code isn't as well integrated as I would like it to be and it'll take some work to get animated models in there. To finish off the day I added billboarded ( always face the camera ) hp bars.
Initially I used spherical billboards for the hp bars, but it looked weird, so I changed it to "camera plane" billboards - I don't know what they are properly called, just billboards that are always parallel to the camera plane. And I also added the actual hp display to the hp bars, the hp value is set as a uniform value in the fragment shader so the rendering of them is fast - currently every hp bar uses its own draw call though - fine for now, but I may want to batch them later. Then I finally added repeating mob waves, before there was just one wave and then I had to restart the game which was getting annoying when trying to test things. And entities got a hitbox and click registration on them and when they are clicked an entity window opens and will show some details about the entity.
Today I worked on projectiles, the towers can actually shoot now and deal damage, instead of the mobs randomly changing hp every few ticks which was weird^^ The projectiles are being rendered similarly to particles, because I want to be able to render a lot of projectiles in the game. Again there are probably some improvements that can be done here but so far it still works good enough.
I started the day by working on multi stage textures for projectiles and did a weird energy ball projectile which rotates, although it's not very visible. However I noticed that the game randomly crashed after 5 to 15 minutes and after a while and almost losing my sanity I found the bug. Remember how I keep the entities in memory after they are dead to dereference them correctly. Well, I may or may not have forgotten to check if the entity is still alive in the tower target aquisition function, so in rare cases the tower update found a new entity in range ( which was already dead at that point and in its last tick of being a zombie ) and spawned a projectile with the entity as its target, then the entity update removed the entity and the projectile update got into undefined behavior when trying to read data from the entity and the game crashed. So I added a is entity alive check to the find target function and went back to... watching netflix and letting the game run in the backround to see if it crashes... ehm work. And it ran for 4 hours and got 1.5k+ kills and didn't crash.
In the evening I worked on some minor improvment, such as not being able to build on waypoints anymore and the hover quad is only shown when actually building something instead of always being there and being annoying.
by Christian - 19.01.2019 - 21:58