First, we have Initialize. Think of this one as putting everything in order to begin the game. In this loop, we're going to set all of our starting points: How much health your guy has, how fast he's going, and all that other fun stuff.
In the next loop, we have Update. In this loop, we determine if anything has changed. For example, did the player press a button? How far did a bullet travel? Is an enemy moving across the screen? How far did he move? This step is pure math.
Next, the fun loop: Draw. This is where all of the changes that we've figured out in the Update loop get written on the screen. After this loop, we drop back to Update.
That's the crux of most games. It's setting the table, seeing what's different, and then displaying the difference to the player.
Going back to our program, they want us to enter in these lines of code:
// Load the player resourcesWhat does this all mean? I dunno. I kind of wish I did. I mean, I added it, and I got the result they were looking for. Anyone out there have a good explanation as to what this all means?
Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X,GraphicsDevice.Viewport.TitleSafeArea.Y +GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
player.Initialize(Content.Load("player"), playerPosition);
In the meantime, here's what we've got after finishing the lesson:
MY GOD IT'S FULL OF STARS |
So not entirely impressive yet, but these things take time. In the next lessons, we'll be learning about input, so it should be much more exciting.
No comments:
Post a Comment