Skip to content

Instantly share code, notes, and snippets.

@todocono
Last active November 1, 2022 06:38
Show Gist options
  • Save todocono/fe042ba0843e2b30dae293424e641080 to your computer and use it in GitHub Desktop.
Save todocono/fe042ba0843e2b30dae293424e641080 to your computer and use it in GitHub Desktop.
int x = 200;
int speed;
void setup() {
size(400, 800);
float r = random(2, 5);
speed = int(r);
noStroke();
}
void draw() {
drawSky();
drawBall();
}
void drawSky() {
int size = 100;
for (int i = 0; i < height; i = i + size) {
float b = map(i, 0, height, 0, 150);
fill(0, 0, b);
rect(0, i, width, size);
println(i);
}
}
void drawBall() {
fill(255);
ellipse(x, 200, 20, 20);
x = x + speed;
if (x > width) {
x = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment