Beep boop. Are you on a mobile device?

codeCampus is a desktop / tablet experience. Log back in on one of those devices and we can get coding!
Banana dance

Chapter 3
Loops!

Pssst...use your keyboard arrows to turn the page!

Arrow keys
Synthia

Helloooooooo, coders! In this chapter, we are going to learn about an important coding concept called loops. Loops are often used to create animations!

1

An animation - like the ones you see in movies and on TV – are made by showing a bunch of still images one after the other. When this is done really fast, then it looks like the characters are really moving!

2

When we create animations, we will have to repeat the same instructions – like showing our sprite’s next costume – over and over and over again.

But here’s the problem: dragging out the same instructions tens, hundreds, or thousands of times would be way. Too. Much. WORK!

Banana split

For example, let’s pretend that we want to make a gigantic banana split, and we need our friend to help us peel 50 bananas.

3

Now, our friend happens to be from another planet, and for some reason, the ONLY sentence she understands is “peel a banana, please!” So if we had to write instructions for our friend, we would need to write that down 50 times for her to peel all 50 of the bananas!

4

But writing that command down 50 times is going to take a LONG time, and it’ll be REALLY boring too. Thankfully, to speed things up, we can use something called a loop!

In programming, a loop is something that allows us to repeat the same command as many times as we want.

Clipboard 5

To use a loop, we would just write, “repeat 50 times: peel a banana please!” and our friend will peel one banana after another until she’s peeled 50 bananas.

Synthia

To recap, a loop is just a way to repeat the same commands as many times as we want. Go back to the dashboard to complete the Paper Activity, 'Simon Says, "Repeat!"'