Miniaturization


Hey, dev-loggers!

Woke up this morning, still half-dreaming, and bam! Hit me like a sack of bricks: block sizes. Even though they were technically working, something just wasn't sitting right. Plus, the whole subgrid system and a bunch of other stuff had me feeling majorly dissatisfied. I thought, "Man, I've got so much already programmed, maybe it's not worth messing with it now." But then I remembered: no deadlines, and let's be real, no funds either! So, what the heck! If I gotta redo half of what I've got, then so be it.


New game plan: Scrap the subgrid system entirely. Everything's gonna be subgrid now! I'm shrinking the tile sizes by fourfold, which should nix the need for subgrid altogether. Also, I'm revamping how I store tile information. No more multiple objects per tile. Now, one object can span multiple tiles, with one tile marked as the pivot.

Bye-bye to all the subgrid and matrix systems I had in place. I whipped up a wizard to create collision meshes, which now consists of a class storing local positions and a boolean for collision presence. The wizard can adjust width, length, and height, with each height layer having its own matrix. This way, I can edit collision matrices with precision.

Now, to see if this works in the game world. I created a class that returns all tiles in the area affected by a block. It's pretty straightforward: pick a pivot tile (for simplicity's sake, it's the bottom-left corner in any collision matrix), then sum up each collision coordinate. Though, rotations threw a wrench into things. Spent ages trying to figure out how to integrate rotations into this system. Even emptied my room and used the floor tiles as a reference. After some trial and error, I cracked it:

RotationOperation
0(y,  x)
1(y,  -x)
2(-y,  -x)
3(-y,  x)

This means adding the collision coordinate multiplied by the operation according to the rotation. Elegant and simple. I might not be a math whiz, and a stronger foundation in matrices might've made life easier, but hey, use what ya got to solve problems as they come up. Tested it in-game, and voilà!


We're almost back where we left off. Here's the breakdown: Before constructing, all tiles affected by a new block are consulted. Each block has a ScriptableObject with PlacingRules. If all rules check out, the block can be placed. One tile is designated as the pivot, marked as the "owner." The owner tile centralizes block info and functions. To remove a block, any tile with a block assigned looks up the owner tile and deletes the block from all affected tiles.

Witness the build and destroy process in action!


Stay tuned for more updates as we continue this wild ride of game development. Catch ya later, dev-loggers!

Get Z-Engine

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.