Created
April 30, 2022 18:19
-
-
Save argestes/1b3cd726606d700c0ba7e59613c4fac0 to your computer and use it in GitHub Desktop.
This file contains 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
void setup() { | |
size(602, 400); | |
ellipse(50, 50, 60, 60); | |
} | |
float xPosition = 100f; | |
float yPosition = 100f; | |
int t = 0; | |
float vX = 3; | |
float vY = 3; | |
boolean enteredFrame = true; | |
float g = 2; | |
// x(t) = x0 + v * t; | |
void draw() { | |
background(255); | |
vY =(g + vY); | |
xPosition = xPosition + vX; | |
yPosition = yPosition + vY; | |
yPosition = Math.max(30f, yPosition); | |
yPosition = Math.min(height - 10f, yPosition); | |
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; | |
vY = vY / 1.15f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment