• Register

Project_BuildTutto is a deep resource management building and crafting game. You own a company that build buildings. To build buildings you have to build all the things. All the things can be built however you want.

Post news Report RSS Project_BuildTutto Development Update 29

In this series of updates I'll document the development process of the game in detail, post timelapse videos of the work, and talk about some features...

Posted by on

Hello everyone!

Stefano here, and welcome to this 29th Project_BuildTutto! This week was an unconventional one since I had to stay away from my working place for the first part of the week, effectively being able to work properly only from Wednesday afternoon. So, not the most changes rich week code-wise, but still important changes have been done to the code base.


IMG CHANGELOG 14


IMG STATS 13


Light Renderer rework

Since I added new kind of lights inside the game in the past weeks, I quickly realized some limitation of my previous light renderer: It could only generate one kind of light. So, I had to revisit part of that code to add support to many different kinds of light, being able to change their size, intensity, and also their color.
So after some of this:

IMG LIGHTFAIL


And some of this:

IMG LIGHTTEST


I finally got a decent light again:

IMG NEWLIGHT


Other than that, since I was already changing that code, I improved the way that the lightmap updates itself.
To briefly recap how my light system works, there are mainly two types of objects to keep in mind: light sources and solid objects that stops light.

  • When a light is placed, the system needs to create its mask by subtracting the shadows created by solid blocks around it to the original light sprite.
  • When a solid block is placed, the system needs to update all the lights to change eventually their mask since a new block is now present on the map.



When I added light to the level there is no big problem since it already checks only the blocks in its range, but when I was adding block I was updating ALL the lights inside the level, even the ones so far away that it would make any difference.
Now I added a 2d vector to hold a map of all the effect areas of lights, so now when a new block is added, I only have to check and update the lights present in that tile, leading to huge improvement on performance.

IMG GRID


This method was kind of obvious and looking back at it it's pretty stupid, but somehow I didn't think about it back then.

Save and load serialization changes

Now that I'm doing a lot of testing on particular setups I really had to improve the loading performance of the game because it was REALLY slow (something like more than 1 minute to load a save file with few objects in it).
The first thing that I discovered to slow down the loading was the loading of all the 2d vectors holding various information about the state of the map.
Those vectors were 100x100 cells, and zooming back I quickly realized how insanely huge was a 100x100 map. An easy and quick fix was to tune down the map size to a still modest 48x48 grid, cutting the serialization time of each 2d vector from +800ms to more or less 200ms.

IMG 48GRID


(This is a 48x48 tiles map)(PS:Don't look at that glitchy fog, I'll fix that later) Another thing to do was to get rid to the hold NVP (name-value pairs) method of serialization in favor of a quicker and simpler binary file method.
This means that first, the serialization was creating an XML-like file holding all the information, but this was extremely inefficient on the performance, and was useful only for debug purpose when I didn't have the knowledge to build a decent serialize function for the objects. Now that the system was working fine, I finally changed back to binary files and the performance improvement was really huge, cutting the vectors loading time by 90% from 200ms to 20ms! Now the games loads itself in a blink of an eye and I finally can test thing much quicker and in a less painful way.

Keep in touch

If you are curious to see how things will go feel free click any of these links to join our community:
Discord Server: Discord.gg
YouTube channel for Timelapses: Youtube.com
Twitter: Twitter.com
Changelog: Docs.google.com

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: