Skip to content

Instantly share code, notes, and snippets.

@Valeria11016
Created May 5, 2025 14:49
Show Gist options
  • Save Valeria11016/6ba7b2477647e00a26ff93c13a552179 to your computer and use it in GitHub Desktop.
Save Valeria11016/6ba7b2477647e00a26ff93c13a552179 to your computer and use it in GitHub Desktop.
float y = 55.0;
float x = 55.0;
float stepY = 3.0;
float stepX = 3.0;
float radio = 55.0;
void setup() {
size(500, 500);
noStroke();
ellipseMode(RADIUS);
}
void draw() {
background(0);
ellipse(x, y, radio, radio);
// Update position
x += stepX;
y += stepY;
// Bounce vertically
if (y > height - radio || y < radio) {
stepY = -stepY;
}
// Bounce horizontally
if (x > width - radio || x < radio) {
stepX = -stepX;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment