Algorithms & Flowcharts
Before you write code, you plan. An algorithm is just a clear plan — and every great game starts with one.
An algorithm is a fancy word for a simple idea: a step-by-step plan to get something done. You already use algorithms every day. Making a sandwich is an algorithm. So is brushing your teeth, or getting ready for school. A programmer just writes these plans down so a computer can follow them.
Order matters — a lot
Because a computer follows steps exactly and in order, the order is everything. Look at this plan to make tea:
Something’s wrong! You poured before boiling. The computer would never fix this for you — it just does step 1, then 2, then 3, and ends up with a mess. Right order = right result.
The correct algorithm is: boil the water → add the tea leaves → wait → pour into the cup. Same steps, sensible order. This is exactly how game code works too: draw the background before the player, or the player gets hidden behind it.
Pseudocode: plain-English code
Pseudocode means writing your plan in plain language that looks like code, before writing the real thing. It helps you think without worrying about exact spelling. Here’s the plan for a simple coin-collecting game:
WHEN the game starts: set score to 0EVERY frame:IF the player touches a coin:add 1 to scoreremove the coindraw the player and the scoreNotice you can understand that even without knowing how to code yet. That’s the point — get the thinking right first, and the code becomes easy.
Flowcharts: drawing the plan
A flowchart is a picture of an algorithm. We use a few standard shapes so everyone reads them the same way:
An oval starts or ends the plan. A rectangle is a step (“move the player”). A diamond asks a yes/no question (“is the score 10?”) and the plan branches based on the answer. Arrows show what happens next.
See an algorithm run, in order
Let’s prove that order matters. The code below draws a scene in three steps — sky, then sun, then ground — exactly in the order written. Run it. Then try swapping the order of the blocks and see how the picture changes.
Each block is one step of the algorithm. Press Run. Then move the “ground” block to the top and run again — watch the sky paint over your ground, because the computer obeys the new order.
Open in the full Game Lab ↗💪 Practice — 10 questions
Answer these to lock in the lesson. Every answer counts toward your progress.
10 questions, auto-graded. Your score is saved to your dashboard and counts toward your phase certificate.
Key takeaways
- An algorithm is a clear, step-by-step plan to get something done.
- Computers follow steps exactly and in order, so the order changes the result.
- Pseudocode is plain-English code that helps you plan before coding.
- Flowcharts draw a plan with ovals (start/end), rectangles (steps), diamonds (decisions) and arrows.
Programming starts with a plan. An algorithm is a step-by-step plan; order matters because computers obey exactly and in sequence. Pseudocode and flowcharts help you design the plan before writing real code — including the rule that you draw backgrounds before the things on top.