I’m pretty new to coding and while playing around with the BouncingBall example I tried to add some air pushing the ball up if the mouse button in pressed, but it looks really goofy because the ball just goes up in a straight line.
I don’t really know what could make it lood better.
PVector location;
PVector velocity;
PVector gravity;
PVector wind;
void setup() {
size(640,360);
location = new PVector(100,100);
velocity = new PVector(1.5,2.1);
gravity = new PVector(0,0.2);
wind = new PVector(0,0.2);
}
void draw() {
background(0);
location.add(velocity);
if (mousePressed) {
velocity.sub(wind);
} else {
location.add(velocity);
}
velocity.add(gravity);
if ((location.x > width) || (location.x < 0)) {
velocity.x = velocity.x * -1;
}
if (location.y > height) {
velocity.y = velocity.y * -0.9;
location.y = height;
}
stroke(255);
strokeWeight(2);
fill(127);
ellipse(location.x,location.y,48,48);
}