Wednesday, March 31, 2010

Globetrotting - Debugging part 2

So, I think I've tracked down the true source of the chug, and it's pretty funny.

You see, the way my drawing code works is that I check to see if the player is on the current floor, and if it is, then draw everything within so many tiles of him. If not, then just skip the entire drawing section. Sounds like a great idea, right?

There's one major problem, and that's that the objects I draw have no place to be until I actually go onto their floor, because their location is based on the draw code. Which means they'll all appear to be on square 0,0 - but won't really be.

The other problem is that while I'm not drawing any of the procdural art for these foors, I am still loading all the movieclips for them. And they don't go invisible until I've left the floor they're on. Which means, if I change the code for things to go invisible as soon as they're loaded, we should lose all the things showing in the top left corner of the map, and thusly the chug with is confirmed to only be associated with them being on the screen.

EDIT: Yep, this solved it. I can now have all the dungeons I want... well, almost. Items are still being annoying, but I figure the majority of the same fix will work for that problem, too.

EDIT2: turns out it was a different problem for the items, though the walls soltion dropped down the chugging by another sizable amount. Every frame something is handled, everything that is being told to calculate what it's doing goes invisible. Every time it's told to draw itself, it becomes visible. Thus, if something is told to draw itself, but then never toldto do anything - it will stay visible forever.

Which brings me to the issue with the items. Items are being held on tiles. Tiles tell the creature on them to calculate what they're doing. The did not, until a moment ago, tell *items* on them to calculate what they're doing. As such, the moment an item appeared on sceen (which before was when it loaded, and now is only when the player walks onto it's map) it stayed there forever, as it didn't get a 'calculate what you're doing' command until someone picked it up.

Now, items are told to figure out what they're doing, even if all that means is that they go invisible - that's what I really wanted them to do anyways...

No comments:

Post a Comment