Hello, game creator! In Module Three, you built your first game with paper and simple digital tools. Now it is time to learn the magic behind the scenes – how games actually work. We will talk about game mechanics (the actions players do) and coding basics (the instructions that make the game run). Do not worry if you have never coded before. We will start with the simplest ideas and build up slowly. By the end of this module, you will understand how to make characters move, jump, collect items, and more!
Kemi loved playing games, but she always wondered, “How does the game know when I press a button?” One day, she met a robot named Robo who could build games. Robo said, “Kemi, a game is just a set of instructions. When you press a key, the game reads the instruction and does something. I will teach you the secret language of games – it is called code.” Robo showed Kemi a list of instructions: “When arrow key pressed, move character right.” Kemi typed it, and the character moved! She then added “If character touches coin, add 1 to score.” The coin disappeared and the score went up. Kemi was amazed. She realised that games are just a series of simple instructions. And she could write them too!
Definition: Game mechanics are the actions that players can do in a game – like jumping, running, collecting, shooting, or building.
Why important: Mechanics are what make a game interactive. Without mechanics, a game is just a picture.
Simple explanation: Mechanics are the “verbs” of the game – what you can do.
Real-life example: In “Super Mario”, the mechanics are jumping and running.
School example: In a typing game, the mechanic is pressing keys to type words.
Home example: In a cooking game, the mechanics are chopping, stirring, and baking.
Nigerian example: In “Ayo”, the mechanics are picking seeds and dropping them in holes.
Illustration:
GAME MECHANICS -------------- - Jump 🦘 - Run 🏃 - Shoot 🔫 - Collect 🪙 - Build 🧱
Mini summary: Mechanics are the actions players can do. They make the game interactive.
Definition: Coding is writing instructions that tell a computer what to do. These instructions are called code.
Why important: Coding is how we make games work. Without code, a game is just a drawing.
Simple explanation: Coding is like writing a recipe for a computer. The computer reads the recipe and does what it says.
Real-life example: When you click “play” on a video, code tells the video to start.
School example: In maths class, you write steps to solve a problem. That is like coding.
Home example: Setting a timer on your phone uses code.
Nigerian example: The app you use for mobile money is made with code.
Illustration:
CODE = INSTRUCTIONS -------------------- Step 1: Start Step 2: Wait for key press Step 3: Move character Step 4: Check if coin collected Step 5: Update score
Mini summary: Coding is writing instructions for a computer. It is the brain of a game.
Definition: An event is something that happens in the game, like a key press, a mouse click, or a collision.
Why important: Events trigger actions in the game. They make the game respond to the player.
Simple explanation: An event is like a doorbell. When you ring it (event), someone opens the door (action).
Real-life example: When you press the “A” key (event), the character jumps (action).
School example: When the teacher says “start” (event), you begin the quiz (action).
Home example: When your phone rings (event), you answer it (action).
Nigerian example: When the referee blows the whistle (event), the football match starts (action).
Illustration:
EVENT → ACTION -------------- Key press → Move character Mouse click → Shoot bullet Collision → Lose a life
Mini summary: Events are things that happen. They cause actions in the game.
Definition: A condition is a check that decides if something should happen. For example: “If the player touches a coin, then add 1 to the score.”
Why important: Conditions allow the game to make decisions. They make the game smart.
Simple explanation: Conditions are like questions the game asks. “Is the player touching the coin?” If yes, do something.
Real-life example: “If it rains, then take an umbrella.”
School example: “If you score 10 points, you win.”
Home example: “If the light is red, stop. If green, go.”
Nigerian example: “If you have the most seeds in Ayo, you win the round.”
Illustration:
IF condition THEN action ------------------------ IF coin touched THEN add score IF enemy touched THEN lose life IF score >= 10 THEN win
Mini summary: Conditions are “if-then” rules. They control what happens based on the game state.
Definition: A loop is a piece of code that repeats a set of instructions over and over.
Why important: Loops save you from writing the same code many times. They make games efficient.
Simple explanation: A loop is like a record player that plays the same song again and again.
Real-life example: A game loop repeats: get input, update game, show output.
School example: In a spelling test, you spell one word, then the next, then the next – that is a loop.
Home example: When you brush your teeth, you move the brush up and down in a loop.
Nigerian example: In “Tinko Tinko”, you repeat the same clapping pattern in a loop.
Illustration:
LOOP
----
while game is running:
get player input
update game
show output
Mini summary: Loops repeat actions. They are used for the game loop and many other things.
Definition: A variable is a box where you store a piece of information, like a score, a name, or a number.
Why important: Variables let the game remember things. Without variables, the game would forget everything.
Simple explanation: A variable is like a labelled jar. You put things in it and take them out later.
Real-life example: The score in a game is stored in a variable called “score”.
School example: Your grade in a subject is a variable – it can change.
Home example: The amount of money in your piggy bank is a variable.
Nigerian example: The number of seeds you have in Ayo is a variable.
Illustration:
VARIABLE = STORAGE BOX ---------------------- score = 0 (start at zero) score = 5 (after collecting 5 coins) score = 10 (after collecting 10 coins)
Mini summary: Variables store information. They can change during the game.
Definition: Moving a character means changing its position on the screen using code.
Why important: Movement is the most basic mechanic in many games. Players need to control characters.
Simple explanation: To move a character, you change its x (left-right) or y (up-down) position.
Real-life example: In a racing game, you press up to move the car forward.
School example: In a drawing game, you move the cursor with the mouse.
Home example: You move the joystick to control a character on the TV.
Nigerian example: In a “Ayo” digital game, you click a hole to move seeds.
Illustration:
MOVE CHARACTER
--------------
if right arrow pressed:
x = x + 5 (move 5 pixels right)
if left arrow pressed:
x = x - 5 (move 5 pixels left)
Mini summary: Movement is controlled by changing the character's x and y coordinates.
Definition: Collision detection is checking if two objects (like a character and a coin) are touching each other.
Why important: Collisions are used for collecting items, hitting enemies, and many other interactions.
Simple explanation: Collision detection is like asking, “Are these two things touching?”
Real-life example: In a game, when Mario touches a mushroom, he gets bigger.
School example: When you drop a piece of paper and it touches the floor, that is a collision.
Home example: When your cup touches the table, it is a collision.
Nigerian example: When the seeds in Ayo touch the opponent's side, they are captured.
Illustration:
COLLISION CHECK
---------------
if character touches coin:
score = score + 1
hide coin
Mini summary: Collision detection checks if objects touch. It is used for collecting, hitting, and more.
Definition: Scoring is counting points. Health is how many lives or hit points a player has.
Why important: Scoring and health give feedback to the player. They show progress and danger.
Simple explanation: Score is like a reward. Health is like a safety bubble that gets smaller.
Real-life example: In a racing game, your score is your position. Health is your car's condition.
School example: In a quiz, score is the number of correct answers. Health might be the number of wrong answers allowed.
Home example: In a board game, score is the number of points. Health might be the number of tokens left.
Nigerian example: In “Ayo”, the score is the number of seeds you captured.
Illustration:
SCORE AND HEALTH ---------------- score = 0 health = 3 if coin collected: score = score + 10 if enemy touched: health = health - 1 if health == 0: game over
Mini summary: Score tracks points. Health tracks lives. Both are important for feedback.
Definition: Sound effects are short sounds that play when something happens, like a coin sound or an explosion sound.
Why important: Sound effects give feedback and make the game more exciting.
Simple explanation: Sound effects are like the voices of the game. They tell you what is happening.
Real-life example: In a shooting game, you hear a “bang” when you shoot.
School example: In a quiz game, you hear a “ding” for a correct answer.
Home example: In a board game, you might say “boom” when a player rolls a six.
Nigerian example: In a digital Ayo game, you hear a “click” when you move seeds.
Illustration:
SOUND EFFECTS ------------- play sound "coin.wav" when coin collected play sound "jump.wav" when character jumps play sound "gameover.wav" when health = 0
Mini summary: Sound effects add fun and feedback. They make the game feel alive.
Definition: A function is a named block of code that does a specific task. You can run it whenever you need it.
Why important: Functions help you avoid repeating code. You write it once and use it many times.
Simple explanation: A function is like a recipe. You give it a name, and whenever you say that name, it does the task.
Real-life example: A “jump” function makes the character jump whenever you call it.
School example: In a spelling test, the function could be “check spelling” – you use it for every word.
Home example: A “make tea” function – every time you say “make tea”, you follow the steps.
Nigerian example: A “capture seeds” function in Ayo – it moves the seeds to your side.
Illustration:
FUNCTION
--------
function jump():
play sound "jump"
move character up
move character down
call jump() when spacebar pressed
Mini summary: Functions are reusable code blocks. They make coding easier and neater.
Definition: Debugging is finding and fixing errors (called bugs) in your code.
Why important: Bugs can make your game crash or act strangely. Debugging makes your game work properly.
Simple explanation: Debugging is like being a detective. You look for clues to find where the problem is.
Real-life example: If your character does not jump when you press the key, you check the code for that key.
School example: If your maths answer is wrong, you check your steps to find the mistake.
Home example: If your phone app crashes, the developer debugs it to fix it.
Nigerian example: If a digital Ayo game freezes, the coder debugs the code.
Illustration:
DEBUGGING STEPS --------------- 1. Find the bug (what is not working?) 2. Understand the bug (why is it happening?) 3. Fix the bug (change the code) 4. Test the fix (does it work now?)
Mini summary: Debugging is fixing code errors. It is an important skill for game makers.
Definition: A sprite is a two-dimensional image or animation that represents a character or object in a game.
Why important: Sprites are what players see. They bring the game to life visually.
Simple explanation: A sprite is like a sticker that you can move around on the screen.
Real-life example: In “Super Mario”, Mario is a sprite. Coins are sprites. Enemies are sprites.
School example: In a drawing program, the shapes you draw are like sprites.
Home example: The pieces in a board game are like sprites.
Nigerian example: In an Ayo game, the seeds and holes are sprites.
Illustration:
SPRITE EXAMPLES --------------- Mario 🧑🦰 Coin 🪙 Enemy 👾 Background 🌳
Mini summary: Sprites are the images in your game. They represent characters, objects, and backgrounds.
Definition: The game loop is the main loop of a game that repeatedly: gets input, updates the game, and draws the screen.
Why important: Without the game loop, the game would not run continuously.
Simple explanation: The game loop is like the heartbeat of the game. It keeps everything moving.
Real-life example: In a racing game, the loop updates the car position, checks collisions, and draws the track.
School example: In a presentation, the loop might be: show slide, wait for click, go to next slide.
Home example: When you watch a movie, the loop plays each frame one after another.
Nigerian example: In a digital Ayo game, the loop checks for clicks, updates the board, and redraws it.
Illustration:
GAME LOOP (in code)
-------------------
while game_running:
handle_input()
update()
draw()
Mini summary: The game loop is the main cycle of a game. It handles input, updates, and drawing.
Definition: Putting it all together means combining all the parts – mechanics, code, sprites, sound – into a complete game.
Why important: This is the final step where your game becomes real and playable.
Simple explanation: It is like baking a cake. You mix all the ingredients (code, art, sound) and bake (test) it.
Real-life example: A team of developers works together to combine art, code, and sound into a game.
School example: After writing a story, you add illustrations and a cover – that is putting it together.
Home example: After building a LEGO set, you have all the pieces in one model.
Nigerian example: A Nigerian game studio combines local stories, art, and code to create a game.
Illustration:
GAME = MECHANICS + CODE + SPRITES + SOUND + POLISH
Mini summary: Putting it all together is the final step. All parts become one working game.
+----------------+
| GAME LOOP |
+----------------+
| INPUT | (keyboard, mouse)
+-------+--------+
|
v
+-------+--------+
| UPDATE | (move, collide, score)
+-------+--------+
|
v
+-------+--------+
| DRAW | (render sprites, UI)
+----------------+
|
v
(loop back to INPUT)
IF (condition is true) THEN
perform action
ELSE
do something else
END IF
score = 0 (declare variable) score = score + 10 (update variable)
| Events | Conditions |
|---|---|
| Triggered by player or time | Checked continuously |
| Example: key pressed | Example: if score > 10 |
| “When” something happens | “If” something is true |
function jump():
sound = "jump.wav"
y = y - 10
wait 0.1 seconds
y = y + 10
You have learned the core of how games work! You now know what game mechanics are and how coding brings them to life. You understand events, conditions, loops, and variables. You can move characters, detect collisions, add scoring, health, and sound effects. You also learned about functions, sprites, and the game loop. Most importantly, you learned that debugging is a normal and useful part of creating games. With these skills, you can start building more complex and interactive games. Keep coding, keep experimenting, and never stop learning!
Match the term on the left with the correct description on the right.
| Term | Description |
|---|---|
| 1. Mechanics | A. Writing instructions for a computer |
| 2. Coding | B. Actions players can do |
| 3. Event | C. If-then rule |
| 4. Condition | D. Something that happens |
| 5. Loop | E. Repeats code |
Answers: 1-B, 2-A, 3-D, 4-C, 5-E
Code a mini-game together: In groups of 3-4, use Scratch to create a simple game with a character that moves using arrow keys and collects items. Each group member is responsible for one part: movement, scoring, collision, or sounds. Present your game to the class.
Design your own mechanic: Think of a new game mechanic that you have never seen before. Draw it, name it, and explain how it would work in a game. Write down the code (pseudocode) that would be needed to implement it.
Create a simple platformer: Using Scratch, build a game where a character jumps over obstacles. Include scoring, a health system, and sound effects. Playtest with classmates and iterate based on feedback.
Code a collecting game: Write a complete game where the player moves a character to collect items. Use variables for score, collisions to collect items, and a game loop to keep the game running. Submit your code and a short explanation.
Add a twist to your game: Take your collecting game and add a new mechanic – for example, a power-up that doubles the score for 5 seconds. Implement this using variables, conditions, and a timer (loop).
Answers to Multiple Choice Questions are provided above. For Fill-in-the-Blank and True/False, answers are in the text.
In Module Five, we will explore advanced game design – including artificial intelligence (AI) for enemies, physics (gravity, bouncing), and creating complex levels. You will also learn how to publish your game online so friends and family can play it. Keep your projects from this module, as we will build on them. Get ready to become a true game developer!
🎉 End of Module Four. You are now a coder and a game designer! Keep coding and creating!