Hi all! Two practical thingies before I start:
* In case you haven't voted for the name of the next version of Olvand, you can still do so here: Goo.gl .
* You may have noted that I said I would invite new groups of playtesters right after the new update was accepted by Desura, but that I was a bit quiet about doing so. This is because my friend, who was so kind to donate some of his server space to me for the olvand.com website, recently migrated his server. We got everything working again quickly (or so we thought), but when I wanted to invite the new players I discovered the mail functionality was broken. This makes it impossible to invite new players. We're working on it!
The reasons for the generator
Alright, about the first new feature in the next version of Olvand: randomly generated monsters. As I explained [here], Olvand's caves are randomly generated, to increase the replayability of the game. However, even if the level is randomly generated, like in Olvand violet, I believe replayability can still go down quickly if the monsters you encounter all behave exactly the same. Instead, I want monsters with varying strategies, a varying set of attacks, varying walking speeds, varying ranges, etcetera. However, I believe most players would not even notice these differences in behavior if all monsters would look exactly the same.
So... randomly generated monster appearances as well. But where do I start? If there's something I learned from creating the [fish generator], then it is that all the little variation I added for the form of the fins and the tails were largely ignored by players. Instead, the main characteristics used by players to distinguish the species were size and color. Differing the size of the monsters is too complicated for now (although very awesome, now that I think of it), so I wanted to start with color.
Picking a (not so) random color
All right, so we need random colors. Good, let's replace all of the colors in our monster sprite with a random other color, and you're done, right?
Yeah, it doesn't work like that, unless you're insterested in creating some futuristic looking aliens. How to find colors that are suitable for monsters? To understand my solution to that problem, you first need to understand how colors work. My guess would be that most of the more technical oriented people reading this know this already, but to be sure: everyone know colors can be built by combining three primary colors, like red, green and blue. There's a second way to create colors, though, and that is to combine hue, saturation and value. Let me show you what these three terms mean:
Value is perhaps the easiest one; it just says how dark or light your color is:
Saturation means how bright or greyish your color is:
And the most important one, at least for our purpose, is hue, which describes whether our color is green, purple, red, yellow, etc.
The idea is that the random color we are looking for should at least have the same value and saturation as the color I originally picked for the monster, so it still feels like the same 'kind' of color; it should just be another hue.
The actual algorithm
So what does the actual algorithm do, then? At first, it analyzes the source image to see which colors it contains. For our monster, this is the result:
For these colors, it calculates hue, value and saturation. (As an aside, these colors have roughly the same hues, but differing values and saturations. This makes them fit together.) It replaces the hue with a random value, and then rebuilds the color. This could result in something like:
On the basis of these colors, it then recolors the monsters themselves. Some results:
Much better, huh? But of course, creating a monster generator is much more than simply changing some colors; I'll show you next week!