AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Short programs and resets

Week 2 · Unit 1: Making programs clear · 3 lessons
2

Reset the start place

Computing 3: Unit 1, pp. 8–27
GoalUse the go to block to put a sprite back at its start place every time the green flag is clicked.
New words
reset · to put something back the way it was at the startx position · how far left or right a sprite is (negative is left)y position · how far up or down a sprite is (negative is down)
Explanation

A program can move a sprite. Click the green flag again and the sprite begins where it stopped last time, not where it began. This is a problem. To fix it, add “go to x: y:” straight after the hat block. The two numbers say where the sprite must start. Take care with the minus sign: x: −180 is on the left, but x: 180 is on the right. A short wait block after it lets you see the sprite at its start place before it moves.

No resetwhenclickedmove200stepsWith resetwhenclickedgo to x:-180y:-40wait1secondsmove200steps
Worked examples
x 240−240y 180−180start x: −180
A boat is placed at x: −180. The program is “move (200) steps” and the boat faces right. The first click takes it to x: 20. With no reset, the second click starts at x: 20 and goes to x: 220. It keeps drifting towards the edge.
x 240−240y 180−180x: −150x: 150
The minus sign matters. The block go to x: (−150) y: (0) puts the fish on the left side. If you forget the minus sign, go to x: (150) y: (0) puts it on the right side.
x 240−240y 180−180x −100, y 80
A block go to x: (−100) y: (80) means 100 to the left of the middle and 80 up. The y number matters too. The picture shows where the sprite will stand.
Class activity

Paper stage: draw a long line on paper and number it from −4 on the left to 4 on the right, with 0 in the middle. A coin is the sprite. The program is: go to x: −3, then change x by 2, then change x by 2. Do the steps on the line and write down where the coin finishes (x: 1). Run it a second time without the go to step and see where the coin ends up. Which version always finishes in the same place?

Practice
1
The sprite faces right. The program is: when green flag clicked, go to x: (−120) y: (0), move (50) steps. Where is the sprite after the first click? And after the second click?
whenclickedgo to x:-120y:0move50steps
2
A sprite is placed at x: −120 facing right. The program has no go to block: when green flag clicked, move (50) steps. Where is it after 3 clicks?
whenclickedmove50steps
3
A sprite must always start in the middle of the left edge. Which block goes right after the hat block: A, B or C?
Ago to x:-200y:0Bgo to x:200y:0Cchange x by-200
4
Why is a wait block useful after a go to block?