Monday, September 12, 2011

Let's Make A Game! Episode 18: Laser Overload

Seriously, adding score and health to this game is EASY. All we did were declare a few variables, loaded a font, added the score up and put it on screen. That's it. I could drop the code in this post, but it's seriously easy to do. It's not even worth discussing.
However, now we're getting into uncharted territory. We have two choices: Keep messing around with this program or move onto the next one. I'd like to keep messing around with this program for a while, I think. Not too long, because this isn't that exciting of a program.

The first thing I'd like to do is fix the shooting. You have to shoot each enemy several times before you kill it, and your character automatically shoots. There has to be a better way of doing it.

I think we should do this: Each bullet is enough to kill an enemy, and the space bar/a forward swipe of the finger shoots. Why? Well, once we start creating a difficulty curve, having each enemy take several bullets is going to be problematic. We also want to turn off auto-shooting because we can seriously make this game ten times better when we give that power to the player.

I've also decided to download a fresh copy of the code and create a backup. If I screw up the code too badly, I can always go back and do more stuff.

Quick Note: This fresh copy of the code has the main character off the screen as well. Ah well. I'm not going to stress about it.

So here's the code I added underneath the UpdatePlayer() method:
// Shooting fix... only fire when we say so

if (currentKeyboardState.IsKeyDown(Keys.Space))

AddProjectile(player.Position + new Vector2(player.Width / 2, 0));

// Play the laser sound

I also went ahead and removed the autofire function. Let's see what happens when we run it.

Well, it only shoots when we press the Space bar, but it shoots too much. It's HILARIOUS, don't get me wrong, but it's a little sloppy. We're on our way, though.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.