level 10
PGraphics path;
float x, y;
PVector location, velocity;
void setup() {
size(400, 200);
path = createGraphics(width, height);
//x = random(width);
//y = random(height);
x = y = 0;
location = new PVector(x, y);
velocity = new PVector(1, 2);
path.beginDraw();
path.background(255);
path.endDraw();
}
void draw() {
location.add(velocity);
velocity.y += 0.1; // the gravity
path.beginDraw();
path.stroke(0);
path.strokeWeight(1);
path.line(x, y, location.x, location.y);
path.endDraw();
if (location.x > width || location.x < 0)
velocity.x *= -1;
if (location.y > height) {
velocity.y *= -0.9;
location.y = height;
}
image(path, 0, 0);
ellipse(location.x, location.y, 20, 20);
x = location.x;
y = location.y;
}
