Thursday, August 28, 2008

Typo and my bool

Notice a problem with this?
if (abs(bullet.xSpeed > 0))

It took me a good 10 minutes to find that problem. Alas, I must have added that typo when I was moving some of my utility functions (min, max, abs) to a more logical home. Ah well.

I also got into trouble last night with bools. Fore some reason, most of the controls for the game worked, but L and R would not. Turns out it has to do with switching from my own typedef'd bool, which was just typedef'd from an integer, to using libnds's bool, which is enum'd as true and false (for those of you used to fancy-schmancy modern languages, C doesn't have a built-in bool, (well, sortof. C99 does, but we won't go there)). I was trying to return a bool value of 512, which using my old method, would evaluate as true. Using libnds's method, it's probably undefined behavior (I'm not sure what the C spec says about doing this), but definitely didn't work. But the fact that it worked for a bunch of other values that I threw at it somewhat incorrectly (32, etc), made it harder to track down.

But I did get a lot more stuff finished off last night. There was a renegade sprite that kept showing up at semi-random times, with semi-random contents. I think I fixed it: it hasn't come back since I changed what I think was causing it (I was using a few partially-uninitialized sprites, in my bullet management code). But, like many intermittant problems, it's hard to know for sure. I also got the currently-selected-item sprite to appear up in the upper-right where it's supposed to.

Next up, moving all the menu/map/etc to the bottom DS screen. I got a start on it last night, but there's plenty more to do.

No comments:

Optimization and C

Starting this next game in C, I've known there will be places where C isn't fast enough, and I'd have to drop to assembly to ...