Before we dive into coding, let’s review some essential coding concepts you’ll need to program your project. Take note of the blocks below; we’ll be using all of them in the programming process.
If/Then Statement
In coding, there’s a tool called the “If-Then” block that lets us give special instructions to computers. Imagine it’s like deciding when to use your umbrella. ‘If it’s raining, then take out your umbrella.’ So, if the sky is pouring, you’ll use the umbrella, but if it’s sunny, you won’t. In the same way, the computer follows the If-Then rule to decide what to do. By adding more directions inside this rule, we can make the computer do all sorts of tasks depending on different situations!
Variables
In coding, we often need to remember or keep track of certain pieces of information. We use something called a ‘variable’ to do this. Imagine a variable as a special kind of backpack. Inside the backpack, you can put different items, and you can also take them out or change them. Just like you might put a book in your backpack today and a lunchbox tomorrow, a variable can hold different data at different times. So, a variable is like the computer’s backpack, helping it remember and carry the information you give it!
“On Dial Turned”
In coding, it’s important to decide when certain things happen. Think of it like a magic button. There’s a special piece of code called ‘key() pressed’ that’s like our magic button. It’s always waiting, or ‘listening,’ for you to press a certain key on your keyboard.
Imagine it’s like a light switch: it can be either ON or OFF. In coding, we call this TRUE (for ON) and FALSE (for OFF). If you press the special key, the ‘key() pressed’ code turns ON (or TRUE), and something fun might happen in a game, like your character jumping! If you don’t press the key, it stays OFF (or FALSE), and nothing happens.
Forever Loop
In coding, there’s a block called the ‘Forever’ block. Imagine you have a toy train that goes around a track. Once you turn it on, it keeps going around and around until you decide to turn it off. That’s how the ‘Forever’ block works in coding. It tells the computer to keep doing something over and over again without stopping.
For example, in a video game, you might have a background with clouds that keep moving across the screen. Instead of telling the computer to move the clouds just once, you’d use the ‘Forever’ block to make the clouds move continuously, creating the illusion that they’re floating by endlessly. So, the ‘Forever’ block is like turning on that toy train, making sure the action keeps going until we choose to stop it!