Game Development Reference
The bounce value has to be negative because bouncing works by reversing the object's velocity. You'll
see how this happens in a moment. A value of ),*3 creates the effect of a moderate bounce. A value
of )- makes the object super bouncy. A value of - makes the object completely bounce-less. Any
value less than )- makes the object look like it's hitting an extremely springy surface, such as a tram-
poline. This is important to keep in mind if you want to make a springing platform in a game.
The [^kqj_a variable doesn't make a further appearance until the section of code that handles stage
All that's happening is that the object's velocity is being multiplied by the [^kqj_a value, which is
negative. If you reverse an object's velocity, it looks as if it is bouncing!
Gravity is just as easy to implement as the other physical forces. All you need to do is create one more
value and add it to the object's [ru velocity.
To see gravity at work, bind the Lh]uan[Cn]repu class to the ?]p symbol. Test the project. The cat
drops to the bottom of the stage. If you press the up arrow key, the cat moves up. When the up arrow
is released again, the cat falls to the ground. When the cat reaches its maximum speed, terminal velocity
displays in the Output panel.