Friday, February 15, 2013
Summary
Today was an excellent and productive thinking day!
As far as code goes, the day was fairly uneventful: I reworked a bit of the rendering engine to change and simplify the way that rendering to a viewer widget works. It's now far cleaner, but I paid a slight performance cost for this cleanliness. Well, at least, in theory I did...but benchmarking afterward yielded no visible slowdown, so that's great! I'm absolutely thrilled with the past few days' advancements, now that it takes only a few lines of code to set up an interface widget that displays a beautiful 3D world
The rest of the day, however, I spent whittling away at a few difficult thinking problems. I think I've just about got the solution to most of them! The first is concerning objects and how they are represented by the game. Consider a weapon. If the weapon is attached to your ship, then it's got quite a good bit of data attached to it: how long before it can shoot again, how damaged it is, what direction it's pointing in, etc. That's the most detailed representation that a weapon can possibly have. Now, on the other end of the spectrum, there are weapon "types," which are the opposite: they're the most abstract representation that a weapon can possibly have. They just define the properties that are common to every single weapon of this type ever. In-between, however, there's this strange land that we need to define in a game in order to be efficient. Consider weapons that are in your cargo, but are not equipped. It would be horrendous to store things like direction, position, remaining cooldown time, etc. for these weapons. They're in your cargo, you're not using them, so why would you store all of that! On the other hand, you
do need to store more data than just the type. What if the particular weapon is damaged? We need to remember that, otherwise repairing would be as easy as un-equipping a weapon then re-equipping it! We might also want to know things like to whom the weapon belongs (perhaps it is stolen), if it has been upgraded in some way, etc.
So the question is: how does one handle this fact elegantly? By elegantly, I mean that there should be a formalized way of reasoning about and distinguishing these "lite" objects from their full-blown versions. Furthermore, code that deals abstractly with these objects (i.e., does not care about position or something like that), should be able to operate on either the full or lite version without requiring duplication. It's an interesting question, and I have a few solutions. Unfortunately, this is one of those questions that does
not reflect a deep question from reality...it arises because we need to optimize. In reality, every instance of an object is a full instance, whether it's in your cargo hold or attached to the ship. I guess in a decade we'll have enough RAM to not have to care about making these kinds of optimizations, but for now, I've run some numbers, and it's necessary. It's a shame, because I'm not big on solving organizational problems that don't have any real-life meaning.
Another big question in my mind today was the ship interface (displaying hardpoints, power distribution, cargo, ship stats, etc). Finally, I think I've come up with a design that I like. Sadly, it will require a bit more interface technology than I've got at the moment, which led me to my next logical question: how to cleanly handle draggable / droppable widgets in an interface. Naturally, I want to be able to drag weapons directly from cargo to hardpoint slots when I'm docked, as it's definitely the most natural way to equip a weapon. Drag/drop isn't trivial functionality, though, although I think I'm converging on a clean implementation
On the music side, I'm still trying to figure out how to get the blood pumping. I can do ambient pretty well, and I'm decent with suspense. But when it comes to full-blown combat music...I'm having a lot of trouble getting something nice. If you've got some game combat music that you particularly like and that you think would be helpful for me to study, post a link!
Hour Tally
Coding: 5.32
Composing: 1.32
Internet: 2.17
Testing: 0.74
Thinking: 2.10
Total Logged Time: 11.65