Sunday, December 4, 2011

Re-do!

Taking more programming classes and learning from, you know, experts, professionals and people who have been doing this for many more years than I have is a good thing, but it has some nasty side effects.

E.G. growing sleazy mustaches

I'm starting to care about things such as efficiency and clarity, and other under-the-hood stuff that I never used to give two thoughts about.

So now that I'm home and I've finally had time to get back to some of my own projects, I'm abhorred by how sloppy my code has been and my driving desire is to make what I have work better.

The result?  Two days of coding delays while I try to merge my new fancy collision system with my old code.
BUILDING PUNCH
What I had been doing wasn't exactly terribly inefficient, per se, it took what needed to be compared and then did the comparisons, but it did so in no organized manner.  Random sections of code in different places all did collision checks by accessing high-level objects in a rather sloppy mess of referencing.  There was no centralized means of checking for these collisions.  Solution?
Pizza.

Well I ended up changing everything around.  I took the collision checking and abstracted it up one level.  What does that mean?  Well I have a super-class called Sprite Object that does most of the heavy lifting of my game objects.  But for the specific game objects I must derive them from the base sprite object, which is like saying a lion is in the cat family, but a member of the cat family is not necessarily a lion.  So instead of doing all of my collision checking in "lion" for all the rest of my objects, I do all of the checking in the "cat family"

That puts all of the collision checking in one place which keeps the checking all very, very simple.  Before, if I wanted to check collisions I was creating new methods in each derived class to do checking against all of the other, different derived classes from the main sprite object.  For a universal necessity I was writing different pieces of code across the spectrum, which makes a bit of sense because an object has to react differently to different collisions.

So I gave the sprite object class a special identifier that marks the object with a certain collision value.  And each object also gets a bitflag value defining which other objects it can collide with.  Once a collision is detected, each object that has a valid collision receives some collision information that stacks up with each overlapping collision.  Then the object, in it's own time, will go through that stack of collision information and decide what to do with each different collision.

This means that, yes, I am still writing code in each derived class for what happens when a collision is registered, but the actually checking for the collision still happens at the surface level without going too deep into the program.
Elephant-charge the cannon-tower!!
This post may be sloppy and hard to follow, but that is my own fault for trying to watch a Christmas movie with family and write at the same time.  I get too focused on one or the other.  But it's vacation, and vacation time must be enjoyed for all it's worth.

I now sit at at the precipice of a very deep and daunting canyon.  It's like the grand canyon, only larger, deeper, and I do not know what's at the bottom.  On the other side lies both what I most desire and fear: completion, finishing, the end, wholeness.



And a face full of FIEAH! (SSB, anyone?)

This may seem like a strange thing to be afraid of, but if you know me well enough you know that I'm prone to incompletion. (Which apparently is not a word recognized by Firefox's dictionary)  I am far from a perfect person, but one of my many faults is the failure to follow through.  I can't begin to list all of the half-finished things in my life.  A million projects, both solo and with friends that I had/still have great faith in and admiration and love for.  Books, games, animations, and even some music, though of all the gifts I've received in my personal life musical ability as I have come to find is most certainly not one of them.  Even simple things such as chores and relationships I will leave undone or put in effort only to eventually retract it.  Especially on the relationship aspect I feel particularly bad, I know a plethora of amazing people on this here chunk of floating space-rock and I feel I have not given enough to them as they deserve.

...but nobody came here to read about that. (..Or did you? How can I know, this is almost like writing a letter to somebody with no pens, paper, and no access to Office Depot?)  So what I wanted to get at was now I have a completely functioning piece of interactive media.  Everything works as I have designed it, now what is left is the small things, adding a Heads Up Display, a menu screen, a means of keeping track of score, adding in controller support, fixing small bugs and polishing the game to make it look better.  I'm the nerdy equivalent of the guy at the gym who lifts a whole bunch of barbells and has massive arms but still has a keg for a stomach because he doesn't want to change his diet or run.  I can jump into a project and do the heavy lifting and feel great when I get the core things finished, but when it comes to the small things they pile up and I feel as if I won't be able to complete all the small tasks, and I don't feel the same rewards as getting a whole system up and running as I do when I add in a HUD or menu screen.  My drive begins to huff and puff, I ran the sprint but making games (and almost everything in life) is won by marathoners, not sprinters.  Anyone can run fast for short distances, it's being able to go the long stretch that counts.  I get interested in other things,  I think of other projects, ideas, or I simply get bored.  There's a good quote (and of course I'm going to paraphrase and not remember who the quote is originally from...) that says (approximately) to never have reasonable goals, as long as you strive to be better than yourself, you will improve.

This, though, I wrote this, I can remember that much.

That must be taken with a grain of salt.  Keep in mind it's easy to distract, discourage, or defeat yourself.  Most of my battles aren't against the world, but are against my own "dark side" which sounds a lot more awesome than the lazy, insecure and instant-gratification-seeking side of myself.

Yeah, I'm done with all the soul searching, my bad.




-Kev
Think I already used this one; not sure, too many doodles cluttering up Blog Space

No comments:

Post a Comment