Sunday, July 19, 2009

Sprites : Gravity Cat


This script block reminds me to the "TurtleGraphics" scenario in the Greenfoot framework. It demonstrates "Pens" tools and a regular moving pattern. It doesn't use "if ... bounce" block but instead uses two move-variables vx and vy. If you observe these two variables, you will see that while vx has a constant value (either 1 or -1), vy variable changes dinamically: it simulates the effect of gravity - the absolute value of vy is greater at a position closer the ground edge (here y=-200) compared to those at a position farther than the ground edge.

No comments:

Post a Comment