So, I think the best thing to do is kind start at the bottom and work our way up. At the base of all these objects we’ve talked about so far, the Species object seems to be the most manageable and smallest on the scale of things, so let’s start fleshing it out.
I don’t even know how to spell UML, and I sure as hell don’t know how to use it properly but I found a UML charting software that’s free called StarUML. You can get it here. I used it just to diagram the basics for us and we won’t be using UML proper at all in these posts.
Here’s the Species class and the things we want to have a species contain.
This is handy because we can create some basic information about the species on-the-fly with just some text, so we could say “Create a species called the Meklar, their type is Robotic, and they build stuff. They like to live on rocky planets.” and we’d chart something like this out:
Nice and neat! Remember, OOP is all about keeping things encapsulated to the object, only exposing stuff as needed. So depending on what language you’re coding in, you could start stamping out a bunch of different kinds of Species:
(Remember, I don’t do UML so please don’t flame me for the mis-use of the line thingies!) 🙂
Now, we should take a look at how a Planet object would exist. What are some traits we’d want? Well, we could match up the type of planetary environment it is and when creating species to live on them, we could take into account the environment:
So although the ideas behind these are language agnostic, I’m going to start working on a couple of Lua examples for the next post! It’s been pretty simple so far, but we’re doing a nice, high-level view of the basics. We’ll get down and dirty next!