• Register

Olvand is a little multiplayer sandbox RPG, where the players live in self-built towns and can go on all kinds of adventures together. Imagine living with your friends in a small town in the mountains, or creating a new group of friends in a pub in the metropole you all live in. There will be several mini-games the inhabitants of a server can play together, among which will be combat based games like King of the Hill or Capture the Flag. You will be able to play against other people in your city, or as a city against another city, or as a whole server against another server. The combat works with self-built guns, in which all kinds of powers can be combined to create unique effects.

Post news Report RSS A new architcture for the monster generator

This week, I give a more detailed insight in how the monster generator is organized

Posted by on

Hi all! I'm happy to tell you that I'm finally back on track, working again on Olvand's next update. The last few blogposts, I mostly told you about what exactly is in these updates, and why. This week, I would like to take a slightly different approach, and tell you about the code architecture. This is because I've spent a lot of time working on integrating the [monster generator] into the game, and I ended up doing it in a much more generic, elegant way than I originally imagined.

The original plan and its downsides

The code for the monster generator already seemed largely finished when I wanted to start integrating it: it could generate monsters with various appearances, various colors, from various sides, and also 'summarize' its creations in 8-character strings, so they could easily be sent around the internet.


My original plan was to simply add this generator to the Olvand repository, and then link to it from other parts of the game. For example, when the server generates a cave, it asks the monster generator for a few 8-character strings that represent monsters, and when the client needs to turn these representations into actual graphics, it again asks the monster generator to do so.

However, there were two main downsides to the original implementation:

* The generator was not easily extendible: adding new bodies, bodyparts, colors, etc. always meant fiddling with the code. While that is not that problematic right now, now I remember how everything works, it will be when I return to this code in, say, 2 years. But more importantly, it won't allow people without access to the source code (=everybody except me) to extend the generator. Over the last few years, I've grown more and more enthousiastic about content creation by the players; it's definitely something I would want to encourage. Closing the whole thing off right now already would be completely opposite to that.

* The generator could only be used for monsters. Just like the fish generator could only be used for fish, the original monster generator could only be used for monsters, despite there being a lot of overlap in their functionality. This is a particularly stupid thing to do because I already have a -spoiler!- fruit generator planned for the next update.

The new architecture

So the new plan is something that can be (1) used for anything and (2) extended without programming. I achieved this with a combination of a special folder structure in combination with JSON configuration files. To understand how that works exactly, you have to realize that all of Olvand's generators work in roughly this way:

1. A base image is chosen
2. "Bodyparts" are merged with this base image
3. The whole thing is recolored


And in the case of the monsters, this has to be done for all positions the monster can be in (looking down, walking west, lying death, etc.). This leads to this folder structure:

code:
Base A
* Side a
  * Bodypart type I
    * Option 1.png
    * Option 2.png
  * Bodypart type II
    * Option 1.png
    * Option 2.png
* Side b
  * Bodypart type I
    * Option 1.png
    * Option 2.png
  * Bodypart type II
    * Option 1.png
    * Option 2.png
Base B
* Side a
  * Bodypart type I
    * Option 1.png
    * Option 2.png
  * Bodypart type II
    * Option 1.png
    * Option 2.png
* Side b
  * Bodypart type I
    * Option 1.png
    * Option 2.png
  * Bodypart type II
    * Option 1.png
    * Option 2.png

 

And obviously, in this example there are only two options for everything, but this can be extended to infinity by simply creating more folders.

So there you have it, a nice and easy system to generate monsters, and anything really. I have to admit the actual system is slightly more complicated, because it also covers animation, but this is not much more than editing a JSON file in the top folder. This is also where you can specify which colors can be varied, and to what extent. Anyway, right now, I'm pretty happy it, and I will be even more when it's time to build the fruit generator!

If you want more development, see [twitter] or [facebook]. If you want to be a tester, you can subscribe on[olvand.com].

Comments
Twillypop
Twillypop

Ah cool. Now the variety will be much more apparent. Nice job and keep at it :)

Reply Good karma Bad karma+2 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Olvand
Platforms
Windows
Creator
Woseseltops
Engine
Custom
Contact
Send Message
Homepage
Olvand.com
Release date
Game watch
Follow
News
Browse
News
New
Post news
Report
Report
Share
Related Games
Olvand
Olvand Role Playing
Related Groups
Indie Devs
Indie Devs Hobbies & Interests with 1,620 members