Please update your browser
Your browser version is not supported by this site. CS First may not work properly. Learn more
In this video, you'll make your game more challenging by shrinking the platform if the sprite touches it.
First, shrink the platform sprite.
With computer science, you can program the computer to do things like this for you.
In this case, you will tell the computer to shrink the platform if the sprite touches it.
To shrink the sprite, click on looks and drag out a change size by block.
Clicking this block makes the sprite bigger.
To make the sprite smaller, change it's value to a negative number.
Cool.
Next, program the platform to shrink if the sprite touches it.
Click control, and place an if block around the change size by block.
From sensing, add a touching block and change the value to the name of the main character sprite.
Now this reads, if touching the sprite, change size by negative ten.
The computer needs to check the if statement the entire time the program is running.
Add a forever block around the if statement, and the when flag clicked block to the top of the code stack.
Test your code to see if that worked.
Great!
When the sprite touches the platform, the platform starts to shrink.
Tinker with the value in the change size block to get an effect that you like for your program.
There is one bug.
The sprite never returns to it's full size.
Anyone who plays this game now will have a tiny platform.
Well that's no fun.
To fix that, put a set size to one hundred percent block under the when flag clicked block.
Great, now the platform will always start the game at full size.
Now it's your turn.
Program the platform to shrink if it's touching the player sprite using change size by, if touching, forever, and when flag clicked blocks.
Reset the platform with the set size block.