Chunks, rooms and more!
Hey! I’m back for this week’s update! So I worked on many different things this week, most of them aren’t completely finished, but I’m happy with the progress I made!
First of all, I added a Chunk system, it’s basically a way to store all my blocks into smaller arrays inside my Chunk objects. I added this system so I can turn some chunks on and off for optimization (not yet added).
I also made a Room system, which I am using for generation. For now, a Room basically decides two random values for the size and creates that room; then it sends the output to my generator class so those blocks that form the room are added to the world and chunks. Rooms are for now only 1 block tall, and their x and z sizes are randomly chosen between 5 and 16.
For the generation of Rooms, I thought of a simple system, basically, I am generating a room with 3-4 “Connector” (each connector has a position value telling where it’s located). To generate more rooms, I look for every connector, get the closest blank position to a connector, and generate a room from that position. That new room will also have connectors betwen 2-3, and I continue for a few rooms, then rooms will have between 0-2 connectors. Later, I will just have to replace connectors with doors and I’ll be set!
Did I trick you? Anyways, here’s a gif of how 2 rooms look like (note, those two are not at the same level only for testing purposes, I changed it so they are.)
Anyways, that’s all I changed that’s important. Next week, I am going to improve and finish the generation system. And start adding some more optimization like chunk loading and unloading based on the player’s position.
Thanks for reading this post! I don’t have any cookies left, you guys ate all of them last time. Instead, here’s a smiley face :)