What this will do is set his y velocity to 0 when he hits the ceiling. You could also make him bounce back down by multiplying his y velocity by -1. You could even substitute the "y position > 179" term with "if [touching edge]"... however, I only recommend this if you don't plan on adding any x movement to Mr. Scratch cat. (Hope this was helpful!)
Well, Professor Wolz, it seems as if the program isn't doing what you didn't ask it to do. The Scratch cat has no idea there's a ceiling! He leaves the screen until his y velocity eventually reaches 0, at which point he's free to fall back down. According to your program, the Scratch cat is SUPPOSED to stay up at the ceiling; the returning speed is in fact completely accurate! ...Now. If you'd like him to stop when he hits the ceiling, I recommend putting in something along the lines of... "[FOREVER [IF [y position > 179] SET y velocity to 0] [WAIT UNTIL [y position < 179]]]"
Download "Gravity"(one sprite and 2 scripts) and open it in Scratch
Project Notes
A simple program to illustrate how gravity influences a "jump." Scratch is given an initial speed (actually a velocity with direction 0). How high Scratch jumps is dependent upon the relationship between the start speed and gravity.
Press the flag to clear the speed and set up the start speed and gravity.
Click the cat to see the relationship.
There IS a bug. When the cat hits the ceiling it stays there.... messing up the calculation of the returning speed. I don't get this. Help!
Comments
You need to be logged in to post comments
Add a Comment
I ran into this problem. Thanks for the perspective on it/
(view all replies)Comment Reply
What this will do is set his y velocity to 0 when he hits the ceiling. You could also make him bounce back down by multiplying his y velocity by -1. You could even substitute the "y position > 179" term with "if [touching edge]"... however, I only recommend this if you don't plan on adding any x movement to Mr. Scratch cat. (Hope this was helpful!)
(view all replies)Comment Reply
Well, Professor Wolz, it seems as if the program isn't doing what you didn't ask it to do. The Scratch cat has no idea there's a ceiling! He leaves the screen until his y velocity eventually reaches 0, at which point he's free to fall back down. According to your program, the Scratch cat is SUPPOSED to stay up at the ceiling; the returning speed is in fact completely accurate! ...Now. If you'd like him to stop when he hits the ceiling, I recommend putting in something along the lines of... "[FOREVER [IF [y position > 179] SET y velocity to 0] [WAIT UNTIL [y position < 179]]]"
(view all replies)Comment Reply