Integers

This is the default variable type in AppGameKit and as mentioned earlier can be used to store positive or negative whole numbers. Here's the kind of data an integer variable may hold.

Variables to store this data could be declared as follows -

currentScore = 0
currentLevel = 0
lives = 0
enemiesRemaining = 0
timeLeft = 0

The name of the variables is entirely your choice. You can use whatever name you want, as long as it doesn't clash with existing commands. You can't have a variable named print as this will conflict with the command called print. The names don't have to be descriptive as shown in the above list. They could be renamed like this.

s = 0
cl = 0
l = 0
e = 0
t = 0

Although that is perfectly valid it's certainly not so clear as in the first attempt at declaring them. When dealing with variables it's a good idea to name them in a descriptive way where possible. Having a variable named enemiesRemaining should make it pretty obvious what kind of data it holds, whereas a variable called e could be just about anything.

You can be more explicit when it comes to declaring variables by specifying the type in the declaration. All of the integer variables can also be declared like this.

currentScore as integer = 0
currentLevel as integer = 0
lives as integer = 0
enemiesRemaining as integer = 0
timeLeft as integer = 0

It is not necessary to give the variable a value when declaring it when using the keywords as integer, in which case it will automatically default to 0. All of these declarations are acceptable.

currentScore as integer = 0
currentLevel as integer = 50
lives as integer
enemiesRemaining as integer
timeLeft = 123

Bear in mind when you declare a variable without specifying its type then you must give it a default value, as shown in the above listing where timeLeft is declared and given a value of 123.