Google+

Friday, September 16, 2011

Let's Make A Game! Episode 20: Kludges And You

I'm just starting programming and I'm already taking the easy way out.

Here's the problem: My character keeps wandering off the screen to the left and on top. It doesn't matter what I do. I've copied the code directly from Microsoft and still get nowhere. It seems it's an issue with the animation somehow, since I don't have this problem without the animation active.

I have two ways I can handle this:
  1. Figure out what's wrong with the animation and fix it. Dig into the numbers and break my brain against the desk until grey matter oozes out and I'm forced to start crying.
  2. Say "screw it" and insert some kludged code to fix the issue.
Guess what I chose!

Right above my MathHelper.Clamp call, I tossed this in:
// Fix the "animation off the screen" problem temporarily

if (player.Position.X <= 50)
player.Position.X = 50;

if (player.Position.Y <= 50)
player.Position.Y = 50;
No more off-screen character! Everyone is happy, although there may still be an underlying problem with this animation. Not sure yet, so it's just a temporary fix (that will probably become permanent knowing myself).

I've also done a few extra things: I was tired of not necessarily knowing when I had died. I decided to toss in a special scream when the character dies and an explosion over the top of the character. It's not pretty, but it's something.

I would like to have the ship move onto the screen to start, have several explosions in a row, and then vanish when the character dies. Not sure how to do that yet. I suspect I'll learn.

No comments:

Post a Comment

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