Tuesday, March 9, 2010

Collision Imminent

I've found the fourth piece. Yes I did. This "fouth piece" is the final bit needed for a game to work from a programming perspective. They are : Drawing Stuff, Controling Stuff, Updating Stuff and now, making stuff Collide.
It did take me the better part of an hour though. The main reason is that I never stopped to consider for a moment what it is the hells I'm trying to summon sometimes. I tried functions that would call for numbers that don't always exist. So on my first try, I went ahead and had the computer go float up the variables from the player bullets. Of course, I ran into an error message as soon as I compiled because no bullets existed. Other times the computer was nice enough to let me know as soon as I typed it out, "Hey, um, yeah, that doesn't work. Quit being stupid."
Floating variables for these particular types of objects is clearly different than floating up player variables. Players are clearly defined and have names. Everything else is just digital huddled masses, like the nameless hordes in Rambo movies that are granted existence only long enough to have it stripped from them forcefully.
So, if I write a function that asks, "Can I have the X and Y for a bullet please?" the answer is rightfully, "The bullet? I have no idea what you are talking about. You fail at life."
"So," I reasoned, "Maybe there must be another way to compare objects."

What I came upon, was buliding a second list. Actually, build several lists of objects. So now there is a list for players, one for player bullets and one for enemies. When I run the enemy update codes (basically the same as the SpriteList from before) I added another little loop inside that also asks, "Hey, while you're here, are you touching any of the player bullets?"
Consequently, it works. They touch and their short, and I have to assume - miserable, lives are wiped out by the raw power of an emerald Bullet Bill.
In any event, with the basic code of collision in place I can get that whole system dancing. My lists are flexible enough to do almost anything with them. Further, they're portable and abstract enough that I can use them in lots of things. Other things, strange things, EP-esque things. I'm quite a happy panda.

- In other news, the Team continues to work along buliding assets for The Thief's Tale. New stuff continues to come in. Sometimes in bursts, other times at a trickle. If you go back, say, 3 months, there was once a tentative Complete Date of the end of January. That didn't happen. Yet, I still continue to believe that a Complete Date will happen.
My belief is granted strength by the periodic infusion of justification.
I've also decided to give The Tester a chance to do some animation. He's been studying dilligently and has learned a good number of things at school, like how to rig up a model. I've found that learning by doing to be the best way (well learning by doing and then writing extensivley about it), and we have time. I'm positive about it.

No comments: