GD2D: dev log #7

Starting from this post, I will write less technical details, because more and more code is written, and writing a detailed post may take more time than actually writing the code.

During this week colliders, opening doors and “actions” were added to the game. This week’s video.

Colliders: naive

Initially I just added a collider for the each wall and use code from platrofmer example to draw colliders on the screen. That works, but very-very slow. This was because the rectangle for the collider was drawn again and again every frame (using immediate : true option). To fix this, I took the following steps:

  • Add geometry to the batcher only once, and just update it’s position every frame;
  • Merge multiple small colliders into bigger one.

Colliders: merged

The colliders were merged using a fairly simple algorithm, but that was enough to make the game quick again. But there was one problem – the walls in the game can appear and disappear, and I do not want to recalculate merged colliders each time wall appear or disappear.

Colliders: unmerge

I used a very simple solution – just did not merge the colliders together when the wall could appear or disappear in this place.

Actions

When you step on some special place or toggle a switch or pick an object several scripted actions can be executed. In other game engines that can be called “triggers”.

I ported the code for the actions from Java.

Currently there are several problems with this code (in some cases the colliders from the walls disappear), but I plan to fix it in a few days.

See you later.

Leave a Reply

Your email address will not be published. Required fields are marked *

*