Variables Intro 2 Solution
Review and using two variables at once. Half day.
-
Arf the Dog gets five points when he eats a cupcake and two points for eating a hotdog. When food is eaten it disappears. Reset the points when you click the green flag.
Arf the Dog:
when green flag clicked set [points v] to (0)
Cupcake:
when green flag clicked forever if < touching [Arf the Dog v] > then change [points v] by (5) hide end end
The hotdog is almost identical to the cupcake.
-
There are two variables. One is a “goal” number. The other is the “current” number.
-
You control the current number with the arrow keys (up, down).
-
When the current number matches the goal number, the backdrop changes to “You Win”.
-
Set the goal number to be a random number 1 to 10 when green flag is clicked.
when green flag clicked set [goal v] to (pick random (1) to (10)) when [up v] key pressed change [current v] by (1) when [down v] key pressed change [current v] by (-1) when green flag clicked forever if < (goal) = (current) > then switch backdrop to [YouWin v] end
-