xxxxxxxxxx
// let sprite, platform;
function setup() {
createCanvas(400, 400);
world.gravity.y = 10; // apply gravity
sprite = new Sprite(250, 50, 40, 40);
sprite.color = 'orange';
// create a static platform at the bottom of the canvas for the sprite to bounce off
platform = new Sprite(250, 280, 500, 20, 'static'); // full-width platform
platform.color = 'gray';
}
function draw() {
clear();
// uncomment to set low bounciness
// sprite.bounciness = 0.5; // low bounce effect
// uncomment to set full bounciness
// sprite.bounciness = 1; // full bounce effect
// uncomment to set no friction
// sprite.friction = 0; // slides freely without resistance
// uncomment to set high friction
// sprite.friction = 10; // resists sliding movement
// uncomment to set no drag
// sprite.drag = 0; // no air resistance
// uncomment to set high drag
// sprite.drag = 10; // strong air resistance effect
// uncomment to allow free rotation
// sprite.rotationLock = false; // can rotate freely
// uncomment to lock rotation
// sprite.rotationLock = true; // rotation is locked
}