I realized a few weeks ago that the game wouldn’t be very exciting with only 1x1 buildings. Not only would the logistical problem solving be limited but visually impaired don’t think it would be all that appealing. With multiple sized buildings there can be much more variety in designs.
When everything is a 1x1 tile things are so much easier, collision detection is just a coordinate lookup in a dictionary/hash map, rotating is around the same point and doesn’t change the bounding box, and connecting belts could use the position of the building offset by 1.
The first thing I decided to tackle was item input and output on belts. With larger budings I thought it would be helpful to have specified positions that belts could connect to. These are independent of the actual building size and model so if there was ever a building with teleportation I could do something like this.
This required me to rewrite the belt building logic that moves items. Before it was simply looking for a building adjacent to the belt and trying to either unload an item or take an item out of the building. But I hope to do a longer blog on belt logic sometime soon.
Secondly collision detection had to be reworked so that all the buildings bounding boxes were checked when placing or tapping on something. This isn’t optimized yet and eventually could be very slow but since this collision detection doesn’t happen every frame (only on user interaction) I’m ok with it for now.
Rotating buildings on a grid doesn’t feel natural to me. A 1x1 rotates around a center point (0.5, 0.5) and the bounding box doesn’t change. However with a 2x1 not only does the bounding box not flip flop width and height but the piviot point can’t be (1, 0.5) otherwise it wouldn’t align to the tiles. To solve this I kept the pivot point at (0.5, 0.5) which works when a building isn’t square. For those it can feel out of place not having the pivot be centered since a square would no longer need to change it’s bounding box when rotating. So for those cases it moves the pivot point to the center. There’s more work that can be done to try and make the pivot closer to the center for large buildings so it doesn’t spin around on a corner.
At this point I want to start adding more content and spend time making 3D models that look good. I don’t have much experience with that so hopefully they don’t turn out garbage. Although there could be a garbage factory for recycling trash 😂.
Follow and Subscribe 👍
This journey is just beginning. If you like what you read I’ll be posting more of it, hopefully weekly. Currently on twitter and instagram sharing images and videos from development. Reach out via email or come join discord!
Email contact ‘at’ builderment ‘dot’ com