Instead, we're going to work off of XNA tutorials to learn the underpinnings of the language itself. Microsoft's site doesn't reveal tutorials unless you really go digging, but I finally found one that's been EXTREMELY helpful. Here's a link if you want to follow along with me.
The idea behind this tutorial is to give us all a better idea of how to build a simple game while walking alongside us with the code. We'll try and follow along.
I hope we're all familiar with the idea of a "variable." In case you're not, a variable is a value that can change over the course of our program. For example, let's take a video game character like Cloud Strife. When he starts out the game, he may have 200 hit points. Over time, that number can change. It can go up, down, or do whatever within certain limits. That's a variable.
There are couple main types of variables that we'll use: integers, Boolean expressions, vectors and textures. Cloud's hit points are an integer, or a whole number.
A boolean expression is something that's either true or false. For example, when Cloud has one or more hit points, he's alive. When he has zero hit points, he's dead. That's a boolean value.
Vectors are the location of an item in 2D or 3D space, and textures are what any given tile will look like, as far as I know. I could be way off on those definitions.
So, if we want to declare a variable, the tutorial suggests that we do something like this:
public int Health;What I've done here is said that this variable is going to be an integer (or "int"). We're naming the variable "Health" and ending the statement with a semicolon to end the "sentence."
This goes hand in hand with the idea behind "methods," or "functions." The nearest analogy I can come up with is this:
During the day, you do several tasks repeatedly. Most boil down to a few basic things. For example, you eat, go to work, brush your teeth, use the bathroom, etc. Each of those individual things you do is comparable to a "method."
For example, when you eat, some of the possible variables could be:
- The food you're eating
- How much time you have to eat
- What utensils you have
- How long you have to work
- What tasks you must accomplish
- Who you're working with
- What you need to do on the way home
- What the traffic is like
- If there are any roads closed
- Initialize
- Update
- Draw
That should give us a good starting point. We'll complete the step called "Creating the Player" and then go from there.
No comments:
Post a Comment