Integers

Let's start with something you already know: numbers.

-5 -4 -3 -2 -1 0 1 2 3 4 5
Integers

Types of data

Games remember lots of different things. Each kind of data is called a type.

String "Alex"

Words and letters

Integer 42

Whole numbers

Boolean True False

Yes or no

What is a variable?

A variable is a name that remembers a value.

🌐 Global: outside every object
score = 0
Inside the Player object
life = 100
hit_power = 10

Variables can change

The value inside a variable can change while the game is playing.

Global variables
Numberscore0
Numberlives3
ConditionAction

PlayerOn collision with Coin

▶

SystemAdd 1 to score

PlayerOn collision with Enemy

▶

SystemSubtract 1 from lives

Hold A or D on the keyboard to play

Booleans

A boolean is a variable with only two values: true or false.

Global variables
🔑

Conditions

A condition is a question. The answer is always true or false.

Global variables
System → Compare variable

If

An if checks a condition. When it is true, the action runs.

Global variables
Numberscore0
Numberlives3

PlayerOn collision with Coin

▶

SystemAdd 1 to score

PlayerOn collision with Enemy

▶

SystemSubtract 1 from lives

IfSystemscore = 5?

▶

TextSet text to "You win!"

IfSystemlives < 1?

▶

PlayerSet animation to "Dead"

Hold A or D on the keyboard to play

Pick your player

Point at an animation to see its frames. Click it to download it!

Pick your enemy

Point at an animation to see its frames. Click it to download it!