In this lesson, students will learn:
- How to render bricks, using a nested loop that works through a two-dimensional array
- How to add a collision detection so it can bounce off the bricks and break them
The For Loop: It lets you repeat a section of code “for any number of times”.
Statement 1: Creates a variable called i (“index”), which is initialized to 0.
Statement 2 defines the condition statement. How many times it should repeat “while the index variable is less than 5.” It starts at 0: 0, 1, 2, 3, 4.
Statement 3 increases the index value by 1 each time the loop runs: i++