Wednesday, August 4, 2010

In Dark Trees

Okay, Flash got me this time. I didn't get much programming done today because I'm still trying to wrap my head around the coral problem. I've got some sort of algorithm for collisions involving the giant bitmap, but I'm not sure how well it's actually going to perform in practice, just in terms of accuracy. Also, a new layer of confusion has just been added. I tried storing each individual coral piece as its own bitmap and updating the position of each bitmap every frame, just out of curiosity.

And... it turns out that I really underestimated how fast bitmapping is compared to spriting. There is NO noticeable slowdown in the game-play, and I made about 45 rows of them! Oddly, though there's no lagging in player controls or whale movement, the bitmaps get spaced incorrectly as you get higher up, which may indicate that Flash is having more trouble iterating through the giant array storing all the bitmaps than copying the pixels. Of course, this is just me guessing, and I could probably get around the problem by dynamically slicing off pieces of the coral array and sticking them back on when they're needed again. since the position of the coral relative to the rest of the coral is always the same, there's no point in updating the position of coral that's off-screen every frame when I can just stick it back on again if it's needed.

So, I'm torn. The large bitmap approach seems undeniably more efficient, but I only have moderate faith in my algorithm. The small bitmap approach makes collisions a lot simpler for me, but possibly a lot more tedious for Flash, and I'm wondering if there's a way to do this that wouldn't result in too much overhead code. I could really use a personal Flash guru right now. If anybody has any suggestions, they are totally welcome. For now, I think I'm gonna take a break for tonight and get the rest I am sorely lacking.

Here's a rushed implementation of the small bitmap method. There's some unfinished code, so it might glitch out a little if you shoot the whales!

Log Entry #1, 8/5/2010: The coral is sort of working! Not very well, but sometimes when you shoot whales at coral of the same color, it disappears! The game's not giving me any errors. Basically I just have to refine the algorithm, which will be a lot of work, but it's still reassuring.

nathan

[EDIT:Moved it again.]

No comments:

Post a Comment