When you click a webpage’s contents, and the webpage responds, how does that happen?
A script is a set of steps that a programmer writes for a computer to follow.
Variables are containers in code that can hold a single number, word, or other information. Variables have three parts: type, name, and value.
Keywords are words that have a preset meaning in a programming language.
If statements run a block of code if the statement's condition is true.
An else statement must be connected to an if statement and will run when the if statement condition is false.
The last type of statement is an else if statement. This type of statement allows a program to react differently to various inputs, enabling more than two paths.
A function is a group of statements in a script that can be reused to perform a specific task.
Parameters are where you provide information that affects how the function runs.
Sprites are images that represent game assets.
Colliders are invisible collision boxes that surround images.
A game mechanic is any active player action or an event within the game. These actions come together to create a compelling game to play.
Loops check a condition and then run a code block. The loop will continue to check and run until the condition is false.
While loops will run forever (until the condition is false).
For loops combine the counting aspect of the while loop into one line.
Arrays are containers that hold variables; they're used to group together similar variables.
But to kids interested in moving forward, it might also help to look at smaller, more specific cases.
User interaction—alerts and buttons
Allowing a user to make in-game decisions can enhance their experience when playing or using a program. For instance, buttons will sit on a web page, waiting to be clicked, and when clicked, will execute a new visual, etc.
An alert, which creates a pop-up on the screen with a message inside of it (like a speech bubble) is one way for a user to interact with web-based code.
A button is another, and it also utilizes a user's input to display different content. This can take advantage of user interaction to make users feel more involved in the program created.
Mouse clicks and physics
A tearable cloth program like the example below uses objects and mouse clicks to determine whether a mouse is moving the material.
How about the classic top-down shooter game, where characters move around and shoot projectiles at enemies? The goal is to avoid the enemies and defeat as many as possible to add to the score!
Random numbers like Yahtzee!
Games use random numbers all the time, right? For instance, worlds in Minecraft are randomly generated when games are started, and in Tetris, random numbers determine the order of new pieces appearing on the board.
Said simply, in games, random numbers add challenges and originality. Other games, like Yahtzee! rely on random number generation to form the core challenge. A for loop can be used to simulate the rolling of dice and randomly generate new numbers each time.
Arrays and a “magic 8 ball”
Machine learning for image recognition and voice controls
Machine learning is one of the fastest growing areas in tech, and it's all about training computers to recognize things like images or sounds!
Putting the pieces together
While getting started is always a challenge, it’s a necessary step for any kid wondering if coding is right for them or not. If so, it’s important to remember that they don’t need to have all of the answers (and you don’t need to have all of the answers either), but they will need outlets to extend their learning.