Skip to content

Instantly share code, notes, and snippets.

@argestes
Created April 30, 2022 18:09
Show Gist options
  • Save argestes/dd1cc9c4ccf361778cfc5d045887ac27 to your computer and use it in GitHub Desktop.
Save argestes/dd1cc9c4ccf361778cfc5d045887ac27 to your computer and use it in GitHub Desktop.
void setup() {
size(600, 400);
ellipse(50, 50, 60, 60);
}
int xPosition = 100;
int yPosition = 100;
int t = 0;
int vX = 3;
int vY = 3;
boolean enteredFrame = true;
// x(t) = x0 + v * t;
void draw() {
background(255);
xPosition = xPosition + vX;
yPosition = yPosition + vY;
ellipse(xPosition, yPosition, 60, 60);
if (xPosition + 30 > width || xPosition - 30 < 0 ) {
vX = vX * -1;
}
if (yPosition + 30 > height || yPosition - 30 < 0) {
//noLoop();
vY = vY * -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment