Here's my solution to problem 1. It is a simple loop with a single
if command to check whether the sprite is over x coordinate zero.
Problem 1 Solution
Here's my solution to problem 2. Note that the cats and dogs don't
do all that much, most of the logic is in the ref sprite
Problem 2 Solution
Posted Monday, July 27
Loops and Conditionals
Use the default cat sprite and stamp its image on the stage to make the following image. You must use a repeat loop, moving the sprite within the loop between stamps.
All the stamps are along the x-axis, so the y-coordinate is always 0. The first stamp location is at x-coordinate -180. You can move to this location before the repeat loop, but all other movement must take place inside the loop.
The cat should be stamped at the following x-coordinates:
- -180
- -120
- -60
- 60
- 120
- 180
Do not stamp at x-coordinate 0.
There are many ways to solve this problem and you are free to use anything you can come up with as long as your solution uses a loop and no more than one movement command in each iteration of the loop. You will also need a conditional statement to avoid stamping at x-coordinate 0.
Messages and Variables
For this problem, create a Scratch project with 3 cat sprites, 3 dog sprites, and a robot sprite. The exact placement of the sprites is not important, and you made need to shrink them to make them all fit on the stage. You should end up with a program looking something like this:
The program should have the following behaviors:
- The robot will keep track of how many times a cat has been clicked on and how many times a dog has been clicked on.
- When a cat is clicked on, it should disappear and the robot should say "cat count #", where '#' is the total number of times a cat has been clicked on.
- When no cats are visible on the screen, they should all reappear (hint: you can use the mod operator to figure out if the total number of cat or dog clicks is an even multiple of three, which is when they should reappear)
- The dogs have exactly the same behavior as the cats, except that the robot announces the total number of dogs clicked on instead of the total number of cats clicked on (by saying "dog count #" where '#' is the total number of times a dog has been clicked on).
- If the robot is clicked it will say "cat count is #" for one second, then "dog count is #" for one second, then "total count is #" for one second; where '#' is replaced with the number of times that thing has been clicked. The "total count" # is the number of cat clicks plus the number of dog clicks.
- When the green flag is clicked, all counts should reset to zero and all sprites should appear.