A way to make a sprite bounce?

Anybody have any idea if there is a way you could make a sprite look like it was bouncing. A student was creating a scene with a bunny and she wanted it to bounce. We tried to play around with x and y but nothing could quite get us there. I am assuming maybe once they have booleans and stuff it may be possible?

Ben,

Just a clarifying question - you would want the first “bounce” to be higher/highest and then each “bounce” afterwards be lower until the bunny rest on the ground? Off the top of my head you could have a variable (“bounce”) that would be equal to the y value and would decrease according to how many time the bunny has touched the ground sprite. You’ll get into this a little bit in Chapter 2 of Unit 3, but the decreasing height on each bounce isn’t taught.

Let me know if you have further questions / if it works!

Brad

If you have a ground sprite you could do:

var sprite = createSprite(200,200);
sprite.setAnimation(“bunny_sprite”);
var ground = createSprite(200,375,400,50);

function draw() {

if (sprite.isTouching(ground)) {

ground.displace(sprite);
sprite.velocityY = -10;

} else {

sprite.velocityY -= 0.5;

}

}