- Learnt28 min · levels, prices and reach from lists
- Basic24 min · the defence
- Challenge 1–327 min · balance, win and lose, a best
- Extrabonus · ship it
Review — money 5 min
- Check the money before building; kills pay where they are counted.
- Pads are clones that know their
my spotand remember they areused. - A bonus between waves gives the player a moment to plan.
Quick-fire
A level 2 tower costs 60 to reach and a level 3 costs 90. Where would you keep those numbers so a teacher could rebalance the game without reading your scripts?
Reveal the answer
In a list. upgrade cost holds 60 then 90; a tower at level 1 pays item 1, at level 2 item 2. Change the list and the game changes — exactly as the level order did in Scroll World.
Today’s Topic 3 min
- A tower’s own
level, for this sprite only upgrade costandupgrade range: the price and the reach, by level- A top level, worked out from the length of a list
- Winning and losing, with Storm Flight’s state
Learning outcome
By the end of this lesson you will be able to:
- Upgrade a clone using prices and values read from lists by its own level.
- Rebalance a game by editing data, not code.
- End a game cleanly in a won or a lost state.
Learnt — upgrades 28 min
1 · An upgrade is two list items
Every tower clone keeps its own level, starting at 1. Two lists hold the upgrade path: upgrade cost is 60, 90, and upgrade range is 184, 240, 300 — the ring’s size at levels 1, 2 and 3.
define upgrade me
if <(money) < (item (level) of [upgrade cost v])> then
set [last upgrade v] to [not enough money]
else
change [money v] by ((0) - (item (level) of [upgrade cost v]))
change [level v] by (1)
switch costume to (join [tower ] (level))
set [range size v] to (item (level) of [upgrade range v])
set [build spot v] to (my spot)
set [last upgrade v] to (join [now level ] (level))
broadcast [upgrade v] and wait
end
when this sprite clicked
upgrade me :: custom
upgrade and resizes itself.How to use this: Click the green flag. A tower is bought on pad 2, then upgraded twice.
2 · The top
Two prices in the list means three levels. A tower whose level is bigger than the list is long has nowhere to go:
if <(level) > (length of [upgrade cost v])> then
set [last upgrade v] to [already at the top]
else
upgrade me :: custom
end
How to use this: Click the green flag. A tower on pad 3 is upgraded three times, with plenty of money.
Basic — the defence 24 min
Open your shop from last lesson and make the towers upgradable.
Step 1 — three looks
- Give the Tower two more costumes,
tower 2andtower 3, on the same canvas so nothing moves. - Give it
level, for this sprite only; a new tower starts at 1.
Step 2 — the lists
upgrade cost: 60, 90.upgrade range: 184, 240, 300.
Step 3 — upgrade me
- Build the My Block from Learnt part 1 on the Tower, with part 2’s top check around it.
- Range:
when I receive [upgrade v]→ ifmy spotisbuild spot, set size torange size.
Step 4 — win or lose
- Repeat waves until the third is over or lives reach 0.
- Then set
statetowonorover, and say which.
How to use this: Click the green flag. Click pads to build, click towers to upgrade. Survive three waves.
An upgrade costs double.
The original Tower is answering too. Put the is clone check on every broadcast that is meant for one tower.
The tower changes costume but the ring stays small.
The Range never heard which pad to resize, or range size was set after the broadcast. Set it first, then broadcast and wait.
A level 3 tower upgrades to “tower 4” and turns invisible.
The top check is missing. That is Learnt part 2.
The game keeps sending waves after the castle falls.
The wave loop only counts waves. It must also stop when lives reaches 0.
The list is the balance
Run the same wave against a level 2 tower twice, changing only one item of upgrade range.
- First with 240 (reach 120), then with 300 (reach 150).
- Use
replace item (2) of [upgrade range v] with (300)— nothing else changes. - Record the kills each time.
How to use this: Click the green flag. The same wave twice; between them, one number in a list is changed.
Teacher note
Game designers call this tuning, and it is done in exactly this way — in tables, not code. A tuning pass where each pupil changes one list item and a partner plays it is a very good use of ten minutes.
Winning and losing
The game must end one way or the other, and stop sending waves when it does.
- Repeat waves until
waveis 3 orlivesis below 1. - Then
stateiswonif there are lives left, andoverif not. - Test the losing ending on purpose, with no towers.
How to use this: Click the green flag. No towers, six lives, waves of four — watch where it stops.
Teacher reveal — the loop
repeat until <<(wave) = (3)> or <(lives) < (1)>>
change [wave v] by (1)
set [bugs to send v] to (4)
broadcast [wave v] and wait
wait until <(bugs alive) = (0)>
end
if <(lives) > (0)> then
set [state v] to [won]
else
set [state v] to [over]
end
Storm Flight’s state again, used for its oldest job: telling every script that the game has finished, and how.
The furthest wave
Keep a best wave that survives a worse game.
- Set it to 0 only when the project is opened.
- At the end of every game, raise it if this game went further.
How to use this: Click the green flag. Two games are played; the second goes worse than the first.
best wave never goes down between games.Teacher note
The fourth “best” in this level — high score, best time, best level, best wave — and by now nobody should need the pattern shown. If a pupil does, point them at their own Cheese Maze.
Ship it
Put the whole arc together into a tower defence game you would hand to somebody else.
- A title that explains clicking pads and towers.
- Four waves that grow, a bonus between them, and a boss at the end.
- Buying, selling and upgrading, with prices from lists.
- Won and over endings, and a best wave.
How to use this: Click the green flag, read the title, then click pads to build and towers to upgrade. Four waves, then the boss.
Teacher note
Every tool in Level 3 is in this one project: clones (the bugs, the towers, the pads), lists (the path, the pads, the prices), My Blocks (buy, upgrade), sprite-only variables (health, level, my spot) and game state (title, play, won, over). It is worth saying so out loud when they finish.
Summary 5 min
- A tower’s own
levelpicks its price and reach from two lists. - The top level is the length of the price list plus one.
- Edit the lists to rebalance the game; the scripts stay the same.
- A broadcast meant for one clone must be ignored by the original: check
is clone. - Loop waves until the game is won or lost, then say which.
- Upgrade
- Paying to make something you already own better.
- Tuning
- Changing numbers to make a game fairer or harder, without changing its code.
- Lookup table
- A list you read by position: level 2’s price is item 2.
- Synthesis
- Putting separate ideas together into one working thing.
Hand in
Save your game. You have finished the Tower Defence arc — and used every tool Level 3 has given you in a single project.