2 years ago

Happy Sunday everyone! No sunday lunch for me today, parents are on holiday

I hope you're all well!

I've been making a new Cave system that should be much more efficient, but it's also less random and will take work to make it look naturally cavelike.


The new system lets me make a path from one end of the map to another, so there'll always been a route.


Gif 1 shows me testing it out with just a single tile representing each part of the cave.

Gif 2 I increased the map size and added more rows and columns.

Gif 3 I tried the same but with a bit more randomness.

Gif 4 I took that data and used it to generate 4x4 chunks with floor and sand representing walls. It mostly worked but there were cases where you couldn't progress.

Gif 5 Got it working and put the proper wall generator in (also added a temp minimap to make testing quicker).

Gif 6 is the current state, made the map size random, increased the chunk size to 10x10 and tried adding some probability to the walls added through the chunk shapes. It works but it's too unreliable and I don't like the random gaps in the walls. I think maybe only having the probability walls on the outside would be best.
I'm going to need lots of preset shapes to make this look nice and cavey.


It wasn't too hard, it was mostly just fiddly. Figuring out the correct way to set the values to later be read by the next step. Then I had my usual issues of "do I need to -1 from the array length/height to stay in bounds or not" and other stupid issues (I accidentally copy and pasted the entire code after itself, so none of my changes were working since they were being overwritten by the old version)

I used the Spelunky method as a foundation/insperation:

http://tinysubversions.com/spelunkyGen/ < amazing write up/explainer on how that works.
https://spelunkyworld.com/original.html < get the original Spelunky for free here, awesome game! (also has the source code)

Obviously there was a lot I had to ignore/change since I'm working from a top down view not a platform game, and I don't want areas that are completely sealed off. But it got my head in the right place.

First I set up a temporary array with the correct number of rows and columns with blank data. Then I pick a random starting column in the first row and run a "while loop" picking a direction setting that coordinates array slot to a value that represents the kind of area that will be later generated. At some point it moves down a row and continues till the end.

Then it's just a bunch of nested "for loops" after each other.
The first 2 go through the rows and columns again, taking the data from the temp array and using it to look up which shape it should make, the shape itself is stored as a string of text, which it then runs through and stores each character as the correct tile type in a ds_grid that builds the room on start up. 0's representing floor, and currently numbers as chance of a wall.

3333

2000

2000

3333

For example, this string would make a room that should generally look like a capital C, the lower the number in the string the less likely it would be created though.

Then it's just another nested set of for loops that goes through the ds_grid looking for floor entries and if it finds any it checks each adjacent cell for free space. If it finds any it sets them to a wall.

After that it's just the room start code that actually places the tiles, checking through the ds_grid and placing whatever tiles it finds. (only for walls since they need to be placed at the correct depth, floor tiles I can just use the draw system which is much quicker and can even be limited to only draw the ones in view)

And that's it really, a few other tweaks here and there to add some variety or randomness.



10 comments

Loading...

Next up

There we go! Features now effect which floor layout parts are used! This was already the case for floors with only one feature, but since I added the multipart Ruins all parts were the same (aka all with water around them).

Still like 200 cards i need so i did another 10 pull and got nothing fancy that I didnt already have

Re-worked the wall code for Caves and Ruins so I can have both tilesets at once, and made it so walls can't generate over the Teleporter/Stairs. Now I just need to figure out how best to stop areas getting blocked off (since you can only mine ore walls)

Doki Doki Literature Club is celebrating Monika's birthday and the 8th anniversary of DDLC with exclusive stickers, avatar frames and backgrounds on Game Jolt! 

Head over to the shop to collect yours 👉 https://gamejolt.com/#shop

#gjbroadcast

Happy GOBtober, and happy birth month everyone! I hope you're all doing well!

Here's what I got done in September!

Original post here: https://www.patreon.com/posts/138550640

Dive into the cozy post-apocalyptic open world of Critter Cove!

Gentleman Rat Studios (@GR-Rob ) describe it as “a little bit Animal Crossing, a little bit Stardew Valley. Maybe even a little bit Windwaker, too."

Wishlist the game: https://bit.ly/CritterCove

oh no!

Had to do a rework of draw ground code, and sort out a patch for existing save files to deal with this issue.

Anyone else suddenly craving cheese pizza???

Testing out some shaders for lava tiles.

Mae Borowski is the main character of Night in the Woods! It's an adventure game that tells the story of her return to her hometown of Possum Springs. She was confirmed as canonically pan in a social media post by the game's creator Scott Benson.

Failed to get the meteorite needed for mega evolution, but i got a shiny at least.

Wasted a bunch of remote raid passes