BEFORE YOU READ: This read is just to inform people of how to start off, you shouldn't only read this. Read this then read other tutorials, or just go read other tutorials, this will sorta cover a lot of stuff, most likely not very efficiently.
Okay, to start off, I'll start simple with some Q&A:
Q: What is a game?
A: A Program geared towards being game.
Q: What is a program?
A: A set of instructions a computer can understand.
To show a very basic program which will print out from 1 to 10, here would be one in "Pseudo Code", "Pseudo Code" is just a fake made up language usually just to show how something will work, kind of like a flowchart.
EG: (Pseudo Code)
Code:
01 Create new variable called "N"
02 Set "N" to "1"
03 While "N" is less than "10", Write "N" and add "1" to it
04 Clear "N"
05 Exit
Now, lets write this out in C# (the line numbers are just for reference)
Code:
01 int N;
02 N = 1;
03 while(N < 10)
04 {
05 Print(N);
06 N = N + 1; // Can also be written as "N += 1;" or "N++;"
07 }
08 N = 0;
Okay, lets piece this apart.
"int N" creates a variable called "N" which is the type of "int", there are two different types of...types. Primitive types and Object Types. More about object types later.
The main primitive data types you need to know are byte, int, float, char, bool, & string.
byte - whole number from 0-255 (Ex. 2, 0, 25, 255)
int - whole number (Ex. 25, -25, 20000, 9001)
float - number with decimals with high precision (Ex. 0, 1.005405045f, 2.54f)
char - pretty much a letter (Ex. 'a', 'q' )
bool - true/false (Ex. true, false, maybe)
string - It's actually an object type, but C# uses it as a primitive, it's a list of chars, so just text
Now, back to the code. A variable is a saved "thing" on the computer. It's saved in memory. So when you allocate "int N", you will have opened a spot up in memory to keep this variable there for later use. Luckily since we're using C# I won't have to talk about managing memory.
Well, we create variable "N", so it's there. The next line "N = 1;" sets that variable in memory to "1", 1 is an integer. So, as of right now, our little "N" is currently 1. We'll hit the next line which is "while(N < 10)", this line is a little more complex. Let's piece it apart.
"while" is a keyword for a loop. A loop is something that happens multiple times. In C# braces ("{" }") tell where a loop is active, if that make sense? Technically all a while requires is a bool in the parenthesis. "N < 10" is a bool value. So we could have a variable being a bool that is set to "N < 10".
So "while(true)" would go forever doing the loop. Meaning the lines
Code:
05 Print(N);
06 N = N + 1; // Can also be written as "N += 1;" or "N++;"
would repeat as long as while is getting true.
Well, lets go through the loop... First it hits the loop as 1, it goes in since N is indeed less than 10. So it goes into the loop, it prints "N". The next line increases N to 2. This will keep going until lets say N is finally added up to 10. Well, if you do notice we have a problem. N is 10, the last thing printed was "9", so it would hit the while(N < 10), and N would be 10. So it would kick out and exit. We would only have 123456789, this is bad. So, lets change "N < 10" to "N <= 10" which means "N is less than or equal to 10."
That fixed our problem.
Well, that's lesson 1. I guess I will add more stuff. Next I may go into objects and classes. I dunno, I'm tired and it's 3AM. I hope the other programmers find mistakes so I can correct em.