Skip to content

Instantly share code, notes, and snippets.

@wedesoft
Created June 11, 2023 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wedesoft/72c22543cbc76feefaa2e5e77c1609d3 to your computer and use it in GitHub Desktop.
Save wedesoft/72c22543cbc76feefaa2e5e77c1609d3 to your computer and use it in GitHub Desktop.
Bouncy ball implemented in Java Processing
float x;
float y;
float vx;
float vy;
int radius;
float ay;
void setup() {
size(1000, 800);
x = 500;
y = 10;
radius = 35;
vx = 0;
vy = 0;
ay = 0.1;
}
void draw() {
background(255, 255, 255);
circle(x, y, radius);
x = x + vx;
y = y + vy;
vy = vy + ay;
if (y + radius > 800 && vy > 0) {
vy = -vy * 0.9;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment