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.
On Start
The “On Start” block in programming is a trigger that activates when the program begins running. It’s like the starting pistol in a race, signaling all the subsequent code to execute in sequence. This block is used to initialize settings, variables, and start functions or processes that need to be set up before anything else happens.
In a video game, the ‘On Start’ block could set the initial score to zero, place the player character at the starting point, and prepare the first level to be displayed. It ensures that everything is in place for the game to function correctly from the moment it starts.
Forever
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.
When Button pressed
It acts as an event handler that waits for a specific user action, like pressing a key or clicking a mouse. When this action happens, the block executes predefined code, allowing the program to react instantly.
For example, in a game, this block might be used to make a character jump when the spacebar is pressed. It listens for the press event and then runs the jump command.
If/Then
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 a computer’s backpack, helping it remember and carry the information you give it!