MORE Caves!
I scrapped the old Cave Gen and started from scratch.
The old version wasn't always able to generate a full path from the entrance to exit, so it was having to reset and try again which was then causing load lag.
Started making a system similar to how Spelunky generates it's rooms.
Each tile here is representative of a single part of a full room. I'm creating a 3 by 3 grid, picking a random start location in the top row setting the grids value. it then chooses to go left/right/down and repeats until the last row of the grid.
1955
Increased the grid size adding more rows and columns. It's still able to generate a full path, but the lack of randomness is a bit more obvious.
1956
Tried tweaking the randomness values a bit
1957
Took that data and translated it into 4x4 tiles, sand represents walls. You can see a path is mostly generated, but there are some mistakes stopping you from getting all the way from start to end.
Each 4x4 is grabbed from arrays built like;
1 1 1 1
0000
0000
1 1 1 1
With 1 being walls, 0 being empty space, I've got different ones to use for if a chunk should be accessed from nowhere/top/bottom/both.
1958
Got it working and put in the old wall placement code so the it's got physical walls now.
Also made a temp minimap from the grid data to help with debugging.
1959
Increased the grid size to 10x10 and tried adding some probability to the walls added through the chunk shapes. Using "2" instead of "1" to tell the system to decide itself whether to make a wall or not.
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 reset shapes to make this look nice and cavey!
1960
No gif, but I've split the Chunk arrays into parts, and am flipping and mirroring them when needed to save having to make loads of arrays. Had to set up a script to grab a string and reverse it, fortunately I found one the Game Maker forums I was able to use.
Got Stairs set up so you can enter and leave the floor from the correct places...but why is there more than one??
Seemed like not destroying the old ones when you change room??
Nope! The dupes were the exit stairs, they just weren't being created in the correct place!
1961
Sorted, fixed their spawn location. There was an issue going outside the grid, so it was defaulting to the start chunk. Now to figure out how I broke the Underground! Most likely tuned off it's gen code with the old cave code by mistake.
1962
Fixed!
1963
Rebuilt and split up the script that grabs the chunk sub-shapes. It was gonna be a massive pain to have just the one script so I split it into the various chunk parts (based on which side is open).
Also cropped the room to remove any extra space when they don't reach the edges, no reason to have wasted space!
1964
Plugged the Ore Vein and Rock Spawn code into the new system and it seems to still work fine!
It does need a rework though, since it's picking a random grid cell each time looking for a valid wall/floor to generate on.
1965
Urgh, had a really dumb bug. Not my fault, Game Makers fault!
I used lots of temporary arrays, but GM doesn't really like doing them, so you have to trick it by setting it as a generic variable first.
You can't just do: var _tempArray[0] = x;
you have to do: var tempArray = -1; tempArray[0] = x;
You also have to reset the value with -1 before you change them, otherwise the new data doesn't replace the old, causing my chunks not to generate correctly.
Build a new Ore Vein System, now it uses the grid data to specifically target chunks that are actually used.
Didn't work though, I set the target values wrong, it's trying to generate in grid [0,0], which isn't always a chunk, whoops!
1967
Working now! Testing just in the starting room, so targeting specific grid positions definitely works. They can even spread to adjacent rooms, which makes the caves a bit more connected and realistic.
1968
Urgh...that's not right. Seems when I did the collision code for tiles I didn't take Rolling into account, so you can clip out of bounds by just rolling at a wall :|
1969
Huh, partially fixed it, but found that rolling into the bottom or right side of a tree makes you not bounce, and rolling into wall tiles you don't bounce either!
Turned out the tree issue was because when you hit a tree I change the scale of it to make it wiggle, swapped it out with a fake scale just for the sprite instead of the object!
Fixed the rolling bug for wall tiles. Had to change the collision check to be for all 4 sides of the player instead of just the one that collides. I guess that makes sense?
1970
Added some variation to the floor of caves, now with dirt!
Also added Lights. One will spawn in each chunk that has a feature, I'll figure something else out though, maybe place random ones when it makes a wall tile?
Additionally made adjustments to the RNG for Rocks/Ores/Veins
1971
New walls for the Underground! Much less melty looking than the old ones! They aren't a bit uniform, so I'll either have to add some variants for the front facing ones (and store the references in the Underground grid), or add some objects like pillars and stuff to break up the shape.
1972
Lol, I broke stairs. You'd enter them and immediately leave again.
Fixed it though. Also updated the first floor of the Caves to use the Stone Walls, that feels right to me.
1973
Started designing some special rooms for the Underground/Caves. First up a kind of Treasure Room!
Need to plan out how the Gates will be lowered by various Buttons!
1974
Reworked how Gates animate, so they can be interrupted by them receiving another button press. Without this you could cheese the gates by pressing them in quick succession.
So from my experiments with Buttons and Gates, it seems you need to have at least as many Buttons as Gates and at least one Button has to control more than one Gate.
If I've got that right I can use this as a framework and just jumble the Button locations on room generation, instead of having to plan out multiple button combinations that are successful.
1975
Realised it would be better if you could see all the gates at once, so I set up a new Camera system where when you enter an area the camera will move to a designated point.
1976
Hmm, tried to set up a pathing system so the Camera can move in more advanced ways but urm...didn't work, it moved the Player instead :/
1977
Well I got the path system working, but instead of stopping at the end point, the Camera came back. Nice effect but not what I wanted!
1978
Fixed it! Turns out that when you generate a path it always starts as a loop, so you have to turn that off in the set up code each time.
Now the Camera can follow a set path!
1979
Fixed the Camera not clamping at the edge of the area. Caused by the room being wider than the chunk.
1980
Made a new Gate sprite! Kinda messed it up a couple times, forgot to measure the space before I animated it T_T
Added wall objects either side for some shape variation. I had to use object instead of tiles since they're smaller than the tiles and that would be meant making a whole new collision system.
Grouped them together more so they fit on the screen, and took out the Camera move since it felt way too cramped.
1981
New Treasure Room type! Pick a path!
Wasn't sure how best to stop you going to both paths so added something so opening a check destroys the buttons. Not really keen on this, since that code would be dormant in every chest.
1982
What if opening a chest destroyed the other one? I like the effect, but still not happy with the chest itself having that code.
1983
What if instead of chests, it's pedestals?
Maybe that would be better for a different room type, maybe as long as theirs something on the pedestal you can leave? But how best to enforce a good sacrifice?
1985
Did a rework of how my Water is done, as it was Water could only exist on the surface, and just wouldn't be drawn underground making black voids appear.
Also did a rework of the Grass Spawn code so I can have Wall Vines you can harvest, need to rework the Item Spawn code now, so they don't pop behind the wall (and go splash in the void).
1986
Added a Shrine, I feel like I want this place to give you buffs/debuffs based on what you offer and who the shrine is for. (totally didn't steal this idea from Ehrgeiz)
Also added Wall Lights to give some more atmosphere.
1987
Cleaned up the room generation code, it was getting kind of unmanageable with the different room layouts. Now each is in their own script.
For some reason this broke some offsets, but it was a quick fix to get them working right again.
1988
Made new Button sprites and adjusted how the collisions work. I've got a circle collision box here but I'm not sure if that's really necessary or not, doesn't seem to really have any benefit.
Also fixed a bug where you could stand at the edge of a Button and it would make Gates rapidly go up and down.
1989
Fixed a bug I've had for ages, when you changed direction when next to a wall you'd get pushed 2 pixels away. Doesn't sound like much but with these Buttons close by you could press them when you didn't want to.
1990
Added a frame around Buttons so they look nicer.
I think this room is too long, I'm gonna rework it so the player still can't see what they're getting but don't have to walk as far.
1991
Added a Wall Panel to give some cryptic info about the room/puzzle. I think I want it to be a bit of a riddle, but how trustworthy should I make it? I want the player to consider their choice and maybe doubt it? But I don't want them to feel cheated or regret it.
1992
Smaller version of the Choice room.
Changed the Lock System so that it locks after you pass the gate.
Also tried fixing the Camera not being centred, but it only works at this zoom level. Need to do some maths!
1993
Tried to add some RNG to the Wall Plaque text, but it didn't work. I wanted to randomly replace some letters with "..."
1995
I think this room is good for now. Here's a zoomed out look at some of the RNG.
1996
Never mind, kept at it!
Set up some RNG to spawn Barrels and Pots in the Treasure rooms. Had to rework their spawn code because the floor under Chests/Pedestals are technically Flooring and they wouldn't spawn on them.
1997
Set up a better way of doing Wall hangings like the Vines and the Banners, slight issue in that it stops the Wall Plaque being spawned.
1998
Fixed it, instead of doing creating them as part of the Wall generation for loops, I set up a second for loop after the important room parts have been generated. This is less efficient, but it was that or add an additional collision check and destroy under for every important room part.
1999
GIF 2000!!
Did a rework of how the chunk parts are done, and set up this new Ruins type, I had to make a exception to skip the code that mirrors the chunk sub-parts for the side rooms, since that would make water spawn down their middles.
2000
I'm not sure what I'm going to use this for, and how much better this is over the basic Cave Gen, it does allow me to do water around the edges which would be a pain otherwise, but there's some issues with this.
I can't crop the top or left parts of the room without running through another set of for loops to shift everything up by 1, at least I should be able to do the right side easily by just changing my grid clamp.
2001
I worked out the crops!
2002
Small fix that's been bothering me, your ears no longer appear over the top of walls when your y coord isn't a multiple of 32. I had to set up a whole new draw thing to draw the walls above everything, but only the specific very specific walls X'D
I should probably take those walls out of the tile placement code, since they don't need to exist anymore!
2003
And with this, they're out! Much fewer tiles are now in use at once!
Initially I thought I'd messed something up because Mining didn't work, but it was all in a check for a valid tile. Whoops!
2004
Items
Added Yogurt and Yeast as items you can get from a Fermentor. I'm not sure if I'll keep Yeast or not, it's needed for Bread but it might be too many steps. It's made from Flour, which is also used for Bread.
It does give more use to the Fermentor, but not sure it's worth complicating the recipe.
1966
Added Pasta, fancy food made in an Oven or bought from a Goblin Restaurant!
Also started work on adding Stat Buffs, kinda of means I have to set up the Stats properly first though...I've been getting away with just having HP/MP this whole time lol
But at least the text displaying correctly lets me know that the lookups are all set up correctly.
2005
Bug Fixes and small Changes
-Added Tile Collisions to the Rolling State.
-Added Dirt Tiles to randomly spawn in Caves.
-Added a Light Size Mod to Light sources, so when turned on the light will grow to the correct size.
-Fixed Rolling into Trees only working when hitting the left or top.
-Fixed Item text going outside the text box.
-Fixed animation bug with the Fermentor causing it to flap open and shut forever.
-Fixed Chest UI when selecting Item amount going to 0 instead of 1 as the minimum amount.
-Fixed a bug where the Minimap would try to add houseparts to Buttons.
-Fixed a bug where Objects that are on Flooring would have their shadow hidden by the Flooring directly 1 tile below them.
-Fixed a bug where parading Goblins jumping out of water were still being cropped.
-Fixed a bug where stopping parading Goblins would cause them not to parade again properly afterwards.
-Fixed Floor check code. I broke it when I updated it to use multiple floor instead of only 1 at a time. It was checking for the floor, but not failing if it found something on the floor.
-Fixed Build code returning junk data when it fails to build.
-Disabled use of Seeds/Shoots/Flowers/Treasure Maps underground. Might bring back Seeds but it's kind of a waste since you can't return to the area?
-Set up a better way of doing shadows for things with irregular shapes.
-Changed Empty Bottles to be filled using the same code as Watering Cans.
-Changed how the Building code checks for valid Flooring, previously it would look for individual Flooring, now it checks each space below the Building to be placed. This lets me have bigger Flooring.
-Changed how the palette swap effects arms, was causing issues with invisible pixels since arms also contain clothing. Need to split them into parts.
-Changed how object depth is defined, it now takes the objects ysize into account.
-Changed Plant Pots to draw the top part of plants using the overlayer and no themselves, so I could increase the Plant Pot sprite height, now they line up better.
Thank you all again so very much for your interest and support, it means the world to me and really helps a lot!
I hope you all have a fantastic May! Please look after yourselves and keep being awesome!
p.s Sorry for the delay, I've had a whole load of issues T_T
On top of everytging, for some reason I can't even upload gifs to imgur anymore? Which was part of my file size reduction method :(
3 comments