Cookies   I display ads to cover the expenses. See the privacy policy for more information. You can keep or reject the ads.

Video thumbnail
I was staring at my screen the other day waiting for inspiration to strike
I wanted to make a game but my mind was frustratingly blank
So I thought maybe I could get the computer to come up with some ideas for me.
I began by creating a list of possible characters like celebrity
Scientist rockstar professor and so on to be the heroes and villains of the game
I then listed some character descriptions to add a bit of flavor as well as some genres themes and goals as I went along
I began developing a simple syntax for certain things for example comma-separated entries inside square brackets
represents a list of options to be picked from randomly or if I say defeat at
Character that indicates that a random character should be generated in its place
In total I ended up with these 15 categories and spent not a small amount of time filling each out with a bunch of entries
The most important category is the templates which determine the different ways that elements can be joined together to form a sentence
to complete these templates
I have some code which first reads the contents of each category into a dictionary and then picks a random
template and fills in the tags
so for example
The character tag gets replaced with a call to the generate character function
Which just picks a random character and also has a chance of adding a description to it and of turning the character into a group
Of characters for some variety so we say we start with this captivating
Template a mood game about theme set setting where you play as character goal. Let's see what this turns into if I let it run
I thought it might be fun to share this online
So I have my little HTML file which gives me this in the browser
to make it less hideous I added a stylesheet and started searching how to write CSS because I've actually never done this before
With a little bit of trial and error I was able to get it looking how I wanted
I think I'm ready to launch my web development career
One thing that was annoying me though was being able to select the text on the generate button
So I looked up how to disable that
The answer was nice and easy. You just add this line
Unless the browser is Safari. Then you have to write it like this
It's a touch different on iOS and also on old versions of Firefox and Internet Explorer and Edge
I think my web development career ends here
The last step was finding somewhere to host this and I came across github pages, which was nice and easy
I just had to create a repository called username dot github dot IO containing my files and it was up
So if you're ever in need of some mostly terrible game ideas, I've got you covered
After clicking through a bunch of rubbish
I came across a prompt where you play as a bunch of ghosts who take up
Beekeeping so that they can have an endless supply of honey to put on their pizza. I thought it was kind of funny
So I decided to mess about with it and see where things went
I began by trying to create a spooky ghost - using what I learned from my recent experiments with clouds.
I like how the ghost fades through objects, but overall the effect is pretty underwhelming. So I thought I'd just make the ghosts completely invisible
If I couldn't manage spooky ghosts, I at least wanted a creepy environment
So I spent a bit of time on this crude little generator to give myself an endless supply of evil looking misshapen trees.
I then needed a terrain to place the trees in and I have this little tool I made for a freelance project recently
where the terrain deforms to fit a path
This works by smoothly raising the height of the terrain to match the path at several points
Which in code looks like this
I do several passes starting with a large radius to capture the rough shape and then smaller and smaller to match the path more accurately
Anyway, that long story was all to say that I used this tool to create a little terrain and then added some fences and spawned
in a bunch of those trees
I then started messing about trying to create some atmosphere
I started with a post-processing shader which gets the depth at each pixel and
Uses a function pretty much identical to what I used for the terrain tool to calculate the density of the fog
I then tried blending between two colors based on the depth and overlaying that on the original image
I played around with some different colors
But the main issue I had was that the sky looked really bland
So as a quick fix, I tried mixing the colors based on the y-axis view direction instead to get a vertical gradient
I definitely need to experiment with this more at one point, but I think it looks ok for now
Ghosts can of course fly through stuff, but it looks gross when you do that because the geometry just gets cut away
I first tried making a transparent shader which fades the Alpha as the camera approaches an object
This works great but transparency is tricky because things need to be drawn from furthest to closest to overlay them properly
It's too slow to sort every pixel by depth though. So the sorting is just done based on the center of each object
Which can be troublesome to avoid these headaches. I decided to try out a technique. I've read about called stippling
How it works is we first create a matrix representing threshold values of a 4x4 block of pixels
We then calculate the coordinate of the current pixel and use it to get the corresponding threshold from the matrix
Finally if the threshold is greater than the current alpha value. We don't draw the pixel
So the result of this is these possible states where in each 4 by 4 block of pixels
We can have just one pixel missing all the way up to 15 of the 16 pixels missing
So this is a sort of stylized way, I guess of having objects fade in and out without having to use actual transparency
Here's the effect in the game world. I'm not sure how well this will actually show up in the video
I think it looks a little odd but definitely a big improvement over just cutting the mesh off
I first heard of this technique
By the way in this interesting breakdown of the graphics of GTA 5 where it's apparently used for smoothing the transition
between different level of detail models
Next up I made some simple bees that buzz randomly around the level
But in order to give them a purpose in life, I needed flowers
So I opened up blender and began modeling. I'm currently trying to make something resembling the dramatically named bleeding-heart
My vague idea was that different plants would have different effects like making bees more productive or extending their lifespan
Now if the play was going to plant these flowers, I needed a way to animate them growing
What I tried was unwrapping the stem in vertical strips like this
so that in a shader I can use that data to tell how far along the stem the current pixel is
I can then just discard any pixel below the current growth percent as for the flowers and leaves which are separate objects
I just scale them up as the stem grows
So in the game, here's a daffodil the bleeding-heart
Foxglove and lily of the valley the flowers will slowly start attracting bees. So let me go on a little gardening spree
All right
so if I descend back to ground level you can see some bees buzzing about
The behavior is a little wonky at the moment and their flight doesn't look terribly bee like
So that's something I need to work on still
In case you're wondering about the colors though
Yellow means that the bee is exploring red means it's heading towards the flower and blue means it's actually interacting with it
When they're planted flowers are grouped into cells like this which speeds up the code for letting a bee locate one that's nearby
because the bee can just pick one at random from the cell it's currently in
Once Il'd done this I started thinking about how the player would actually obtain the seeds and came to the logical conclusion that you'd have
To kill giant spiders and trade their souls with the friendly skeleton gardener
So I began trying to create a little walking system for the spiders
Essentially how this works is each leg has an ideal resting position and once it gets too far away from that it takes a step forward
with a little work I expanded the system to eight legs to make this horrifying spider
the advantage of course with this kind of
Animation through programming is that the creature can adapt to the terrain and not just look like it's gliding over it
Now admittedly my results is quite janky looking but I still think it's kind of cool
I'm not going to go over the code for this now both because it's some of the most horrendous code ever written and also because
I'd like to experiment more and explore the topic of procedural animation in its own episode
Anyway, I now have spiders creeping about which brings us back to
So that's what I have so far of this strange little project I don't really have the motivation to keep working on it
So I mean to leave it unfinished for now
But I've learnt a bunch of little things along the way and it sparked ideas for future experiments
So I think it was a worthwhile project despite my failure to see it through to the end
I hope you've enjoyed watching and until next time Cheers