carrotcake Blog 🍃


official devlog for carrotcake written by Louis Durrant

Thursday Report: RNG Trees

Posted on Sep 13, 2018

Every Thursday I write up a report on my latest developments and thoughts if to do nothing more than keep myself accountable. Enjoy!

I always knew I wanted some kind of random generation when it came to the game’s environment. To what exact extent, I’m still undecided. Currently I’m fond of the idea that there will be a number of large ‘parcels’ have predetermined features — certain elevation, certain water features etc. When a new game would be made, these parcels would be pieced together randomly, like a jigsaw with hundreds of different outcomes. I think this would give a good balance of random and predictable outcomes, which would make things more manageable but also fresh.

I’m still new at all this, so I’ve decided to start by building a ‘Spawn Sheet’. This is a sheet of many points, wherein each point rolls a digital dice. Depending on the number that lands, depends on what will be generated — a bush, a flower and so on. Then, once that’s been decided, another dice is rolled to determine whether this prop will spawn at all. I’ve called this ‘likelihood’ and I simply rank it from 1–100: 100 means it’s guaranteed to spawn, 1 and it will never spawn.

I can see this system getting out of hand very quickly since it’s so simple. Currently this spawns 1 of 4 outcomes, but once hundreds of different props are added to the game, I’ll need to figure out something more modular.

Having each point running it’s own code is probably a messy solution too. There will be thousands of points in a single game, so I’ll likely need to think of a way to generate each point through code, instead of plonking it down myself.

Still, I’m proud of delivering something that works at all. It’s exciting seeing the game do so much work for me already, and my main game scene is no longer filled with a hundred flower nodes that I’ve been having to sift through to find the player.

A small bit of code randomly shifts each point so there’s no obvious grid — things look more organic this way.

Eventually stricter rules will need to be in place. Certain zones might spawn more fir trees, for instance. Three bushes should never spawn directly on top of one another, for instance. That should come eventually.

‘Tellstone’ now has both placeholder walking animations. I originally envisioned his foot sprite swapping out for a version that shows the base of his foot, in front of his body. Godot doesn’t offer a super-easy way of swapping out sprites, or even showing and hiding certain sprites in its built in animation system, not without attaching code that triggers when a specific keyframe is played.

I’m actually very happy with the current animation without the foot coming up over his body. It’s surprising how much just shifting a still-sprite gives the illusion of weight and depth. I’m keen to return to the animation to give his backpack more of a clumsy heaviness, because it looks too rigid at the moment. He’s a comedic character, so I want that to come through in his animation.

Character’s now face the player when they talk to one another. This was far more simple than I anticipated — I simply deducted the character’s position from the player’s position. If the number is below 0, the character knows to turn to the left, and visa versa.

I decided that characters would always face forward when speaking. This not only simplifies the checks on where the player is standing, but also means all the fun expressions the characters will show won’t be lost to the player. It also doesn’t look as outlandish as I had worried.

Next week I’m hoping to make a solid start with the tools the player will use throughout the game, starting with the trowel, so that the player may dig small holes with which to place seeds in to cultivate their garden.

Follow me on Twitter.