Definition: A variable is a storage place for a piece of information that can be changed during the game.
Variable Definition: How to make a variable.
ProtectionLevel Type variableName;
Examples using the four most common variable types:
public int health; //an integer variable can hold a + or – whole number
public float money; //a float can store a + or – decimal number
public string playerName; //a String stores text
public bool alive; //a boolean stores a value of true or false
How to assign or store a value in a variable:
variableName = value;
Examples of storing values in the four most common types:
health = 100;
money = 50.25f; // f after a number tells the computer to make it a float
charName = “Fred”; // put quotes “” around the text you want to store in a string
alive = true;