Created
May 5, 2025 14:49
-
-
Save Valeria11016/6ba7b2477647e00a26ff93c13a552179 to your computer and use it in GitHub Desktop.
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 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