Stefano here and welcome to this brand new Project_BuildTutto Update!
Pretty happy with this week's results, there were a lot of structural improvements and new objects, all spiced up with the usual performance improvements which are always nice.
This is a really nice improvement. Before the introduction of this class all the static objects (the ones that doesn't really need an Update event each step because don't do anything fancy after their installation) were instantiated and managed just like all the other objects like furnaces and machines. This was a bit unnecessary and ugly to work with since the Level class needed to pass through every floor tile and wall tile individually once to update them doing nothing and once to draw them one by one.
This class changed a lot. Now when a wall or floor (or anything static) is installed in the map, the important information of it is moved inside this structuresManager class, stored in a 2d vector grid and the original object is destroyed, saving a lot of space and compacting all the data into a more easily accessible structure.
This class has also a single big bitmap which updates each time an object is added or removed, so the player doesn't notice any changes and the game keep showing these objects like they are still individual pieces.
Other than performance improvements, this class also give me a much more comfortable place to work on more complex mechanics like the structural strength of the building the player will create or the roof/wall/foundation system which I'll talk more in-depth later.
NB: Both Foundations and Roofs sprites are WIP, in two weeks I'll take a whole week to try improving the general graphics of each tile.
Foundations are always a really important part of any building, and in the game this fact is still true. Now the player can't simply place stuff like walls and floors anywhere he wants, but he has to build foundations first to handle the weight of the thing he wants to build in that tile. He'll also need to create strong enough foundation because obviously he can't place too much weight on a foundation made of simple wood (or glass if he is really a madman), because eventually those will collapse leading to very ugly situations.
Roofs are another really important piece of this huge puzzle. The player will have to think a good way to build roofs to cover his building, but that's not it. Eventually I'll add the possibility to build more than one floor in a building, so roofs will need to be perfectly planned to be able to sustain the weight of the floors above it.
Different materials will lead to different roofs with different properties. For example, an iron roof is more rigid than a wood one, so it can extend further away from the wall supporting it without having an intermediate wall to support its distance, BUT an iron roof weights much more than a wood one, so the supporting wall needs to be able to support all that weight, otherwise it will collapse leading to other ugly situations.
The “calculation of the distance of each wall to their support” algorithm took a big bite into my mental sanity since it had to support a whole bunch of different situations like:
- Adding a new roof
- Adding a new wall below an existent roof and update all the distances correctly
- Adding a new roof that connects to another roof leading to a different balancing of their weights
- Removing a wall below a roof and updating the new distances
- Removing a roof disconnecting two chunks of roofs previously linked
- Being able to always know on which wall each roof is supported
- Being able to know the total weight each wall is supporting
- And other very situational conditions...
Foundations/Roof View Mode
Since both foundations and roofs are normally invisible or hided away from the player view, I added two more "special" view in the view mode to be able to see and easily manage roofs and foundations.
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