Skip to content

Instantly share code, notes, and snippets.

@declann
Last active November 18, 2021 12:44
Show Gist options
  • Save declann/bada28c7e828894394f7e16b1aae933c to your computer and use it in GitHub Desktop.
Save declann/bada28c7e828894394f7e16b1aae933c to your computer and use it in GitHub Desktop.
brets bounce
p5(sketch => {
sketch.setup = function () {
sketch.createCanvas(width, 200);
};
var x = 0, y = 50, dy = 0;
sketch.draw = function () {
if (x > 600) { x = 0; y = 50; dy = 0; }
sketch.background("#001b42");
x += dx_in;
y += dy;
if (y > 185) {
dy = - dy;
sketch.ellipse(x, 190, 36, 25);
} else {
dy = dy * dampener_in + 3;
sketch.ellipse(x, y, 30, 30);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment