### Connor - Programming Review Lesson 1 and notes

This is a simple review of the first 6 hours coding we've done together so far. If you want we can use this site deliberately to build up a record of the ideas and syntax you've had to learn so far.

This actual page will be updated with bits of code and maybe some pictures as necessary. We can also build you a site of your own to play with if you want to do html/css.

Finally, we can also work out a means of summarising our maths lessons and your own maths knowledge here if you want.

This is the stuff we covered last week and previously:

• Unity - Window layout and the console
• Running a game
• Unity - adding a script to a game object (new empty)
• Editing a script in Visual Studio and saving it.

Programming ideas:

• Startonce and update - Unity specific
	//A class is a cookie cutter for an object
public class NumberWizard : MonoBehaviour
{
//Some boxes to hold our min/max and initial guess
int max = 1000;
int min = 1;
int guess = 500;

//This only happens once, when you first play the game in Unity
void Start()
{
print("Welcome to Number Wizard");
print("The highest number you can pick is " + max); //Remember we could add the contents of a box, the value within to be printed out.
print("The minimum number you can pick is " + min);

print("Is the number higher or lower than 500?");
print("Up = for higher, down = lower, return = equals");

}

//We decided that this is being used twice, so we made a new function. It's selfish (Void). It does it's job but gives nothing back.
void Guess()
{
guess = (max + min) / 2;
print("Higher or lower than" + guess);
}

// Update is called once per frame - this is specific to Unity
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow)) //What key did we press?
{
min = guess; //Notice we use a different box to put our guess in depending if you hit up or down arrow.
Guess(); //Call our Guess function
} else if (Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
Guess();
}
else if (Input.GetKeyDown(KeyCode.Return))
{
print("I won so na na ne na nah!!!");
}
}

}


Some terminalogy used so far:

• Variables - a box to store one thing in.
•         void HelloWorld()
{
//Box for a whole number
int a = 10;
//Box for a floating point number - there are a few of these
float b = 10.1;
//Box for a string of charactors
string name = "Hello World";
//Print out the stuff stored in the box called name
Console.WriteLine(name);
}

• What on earth is a Type? It's a special type of thing you know.
• Writing things to the screen
• Checking what key was pressed and responding -Tests and events
• Making choices: Guessing game with the IF statement
• Loops - lets repeat ourselves until something changes.
• Void - the selfish function
• Unselfish functions - they always give you something back - because they have to, otherwise they'd be void.
• Don't repeat yourself, putting repeated things in a function. Remember the box idea?
• Arrays - they're just a bunch of variables with a house number attached to each right?
• 2D arrays - remember how annoying it was to find out what the numbers were going to be?
• Drawing squares

This is a bonus bit: I think you should consider knowing this :). http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1