Wednesday, July 27, 2011

I'm back!

Well, slightly.

After much putting-off and, now that my shoulder is better, a whole lot of working, I finally got back to the game, and the original game that I'm working on with David, no less.  I didn't actually change a whole lot as of yet, but I've gone back and did some work on my linked sprites.

If you recall, from so very, very, very long ago I devised the system (or rather, I devised my own system) that wold allow me to link sprites together so they would rotate, scale, move and do all of that fancy stuff together.  Well as it would turn out, if I wanted to link in any sort of meaningful way, I'd have issues.

Here's how it works: If one image was to be rotated, it would rotate, then it would call on it's linked images to rotate individually.  Which for figure 1, works just fine and dandy.

HOWEVER, if I had a situation such as figure 2.1 or 2.2, then problems begin to arise.  In figure 2.1, only the first and second image would be rotated, because the third image is attached to the second, but the second doesn't go through it's own linked list, because if it did it would also rotate the first image because the two are linked.  Then there would be infinite rotation and the program would crash.

Same for figure 2.2, if they went through all of the links, each image would keep thinking "oh! I'm linked with him, let's rotate!" when they go to be rotate themselves, resulting in infinite stupidity.


The solution?  Well it kind of makes sense, but it was rather frustrating to implement.

Every time an image calls for a rotation, it passes to the next image it's own personal ID number, and the ID number of the other images that the original is linked too.  These ID numbers become "off limits" and if the second image tries to change any of these images, either the original image or an image that the original image will change in a later update, it is barred from doing so.  Which means a few things: I can be, in a sense, pretty sloppy with how I link images.  I don't have to be certain that images are only linked in a certain fashion, I can link however many I want, in any way I want and it will all be fine and dandy the minute I  try and adjust even one of them.  Not to say that I can just go crazy with linking images as that would probably kill the heck out of my processor, but one image can be linked to many, and they will all function properly.  Any linked image can be tweaked, and all will be effected, and the game won't crash.

Later, I added in one-way linking, which I should have done from the beginning, but one-way linking means one image is considered the base, changes to the base will affect the secondary, but changes to the secondary will not affect the base.  Cool?  Meh. Useful? Um, sure?

The whole exercise?
Hopefully it will be of much use in the future, for the sake of this game, it doesn't change a whole lot, but it enables me to get back on the saddle, so to speak.

I work at the lake tomorrow, but hopefully I'll get some coding in!

Until next time (hopefully not so long as this...)


-Kev

No comments:

Post a Comment