- Learnt28 min · a price, and kills that pay
- Basic24 min · the shop
- Challenge 1–327 min · paying twice, a bonus, selling
- Extrabonus · saving pays
Review — towers 5 min
- A tower is a ring; each bug asks whether it is touching one.
- Every bug has its own health, and deletes itself at 0.
- Clones hear broadcasts too, so only the original builds.
Quick-fire
Last lesson you could build as many towers as you liked. Why is that a bad game?
Reveal the answer
There is no decision to make. Fill every pad and wait. A price turns building into a choice — this pad or that one, now or later — and a game is mostly choices.
Today’s Topic 3 min
money, a price, andif <(money) < (50)> then- A bounty: each kill pays
- Clickable pads, as clones that know their own number
- A My Block,
buy tower at (spot), used by every pad
Learning outcome
By the end of this lesson you will be able to:
- Charge for something, and refuse it when the player cannot pay.
- Let clones be clicked, each knowing which one it is.
- Balance what things cost against what the player earns.
Learnt — money 28 min
1 · A price
Every build now goes through one My Block, which checks the money first:
define buy tower at (spot)
if <(money) < (50)> then
say [Not enough money.] for (0.8) seconds
else
change [money v] by (-50)
set [build spot v] to (spot)
set [build x v] to (item (spot) of [spot x v])
set [build y v] to (item (spot) of [spot y v])
broadcast [build tower v] and wait
end
How to use this: Click the green flag. Three pads are clicked for you, one after another.
2 · Kills pay
One more block in the bug’s hurt script, where it deletes itself: change [money v] by (10). Now the defence pays for its own growth — the better it does, the more it can build.
How to use this: Click the green flag. One tower, a wave of ten, and a second tower bought as soon as there is money for it.
Basic — the shop 24 min
Replace last lesson’s free towers with pads you click to buy.
Step 1 — pads as clones
- Draw a Pad sprite: a square with a plus on it.
- Give it
my spotandused, for this sprite only. - When the flag is clicked, the original makes one clone per line of
spot x, settingmy spotto 1, 2, 3… first.
Step 2 — the price
- Make
money, start it at 100, and show it on the Stage. - Make the
buy tower at (spot)block on the Pad sprite. when this sprite clicked→buy tower at (my spot) :: custom.
Step 3 — the bounty
- In the bug’s hurt script, pay 10 before it deletes itself.
- Send three waves, a little bigger each time.
How to use this: Click the green flag, then click pads to build towers before and between waves. Watch your money.
Every pad builds on the same spot.
my spot is for all sprites, so every clone reads the last number. Make it for this sprite only.
Clicking does nothing.
The original is hidden, and hidden sprites cannot be clicked — which is fine. Check the clones show when they start.
Money goes below 0.
The charge happens before the check, or outside the else.
Clicking a pad twice builds two towers there.
That is Challenge 1.
Paying twice
Click the same pad twice and a second tower goes up on top of the first — and you are charged for it. Make a pad remember.
- After a successful build, the pad sets its
usedto 1 and hides. - A click on a used pad is refused.
- Money after two clicks on one pad: 50, not 0.
How to use this: Click the green flag. Pad 2 is clicked twice.
Teacher note
Last lesson showed two towers on one pad are worth no more than one. So the double build is not just a waste of money — it is the player being charged for nothing, which is the kind of bug players never forgive.
A bonus between waves
Surviving a wave pays 20 — and gives the player a moment to spend it.
- After each wave, change money by 20 and say so.
- Wait before the next wave, so there is time to build.
How to use this: Click the green flag and watch the money after each wave.
Teacher note
The pause is the real point. A tower defence game has a rhythm — tension during a wave, planning between them — and the bonus is what makes the planning matter.
Selling
Let the player sell a tower back for half its price, and free the pad again.
- A
sellbroadcast; the Tower and Range clones on that pad delete themselves. - The pad for that spot sets
usedback to 0 and shows again. - The player gets 25 back.
How to use this: Click the green flag. A tower is bought on pad 3, then sold.
Teacher reveal — who deletes
when I receive [sell v]
if <(my spot) = (build spot)> then
delete this clone
end
Tower and Range both need this script. The original also hears sell — but delete this clone does nothing to an original, so it is harmless here.
Saving pays
At the end of each wave, add a tenth of the player’s money, rounded. Now saving is a real choice against spending.
change [money v] by (round ((money) / (10)))after every wave.- Say how much was paid.
How to use this: Click the green flag and read the money after each of two waves.
Teacher note
The round matters: a tenth of 99 is 9.9, and money like 108.9 looks broken. The same float trap as the Bubble Popper worths.
Summary 5 min
- Check the money before building, never after.
- A kill pays in the same place it is counted.
- Pads are clones that know their own
my spot, and remember when they areused. - A bonus, a sale and interest are all just changes to one variable at the right moment.
- Price
- What something costs to build.
- Bounty
- What an enemy pays when it is defeated.
- Economy
- How money comes into a game and goes out of it.
- Interest
- A reward for saving, as a share of what you have.
Hand in
Save your game. Next lesson, towers can be upgraded — and the price list is a list.