Tuesday, 01 May 2007

Bullets

I've been playing around a lot and browsing copious amounts XNA tutorials. Some of them amazing, some of them outright lame (I'm not going to link the lame ones).

I figured out how I'm going to do gamestate. I've tried a number of different ways and the one that I think works best is to maintain a stack of "GameScreen" objects. Each game screen is loaded on the top of the stack and disables the one before it. As the screen is dismissed, it reveals the previous one.

I have a working copy--screenshot won't show much though:




I've also been playing around with additive transparency on sprites. Most notably, for glowy bullets. I managed to get bullets but they're not really "glowy":


Oh, and ArcTan(x/y)--how I hate thee. Turns out that if you divide a negative by a negative then you get a positive--who would have guessed *grin*.

I had to do this hacky check to get my firing angle to work:

firingAngle = (float)(Math.Atan((double)y / (double)x));
if (x < 0) firingAngle += MathHelper.Pi;

And with that, it's off to bed.

1 comment:

Norman said...

or:

firingAngle = (float)(Math.Atan2((double)y, (double)x));

:-)