Created
June 11, 2023 13:34
-
-
Save wedesoft/72c22543cbc76feefaa2e5e77c1609d3 to your computer and use it in GitHub Desktop.
Bouncy ball implemented in Java Processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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