Page MenuHomec4science

Mover.pde
No OneTemporary

File Metadata

Created
Sun, Apr 27, 01:28

Mover.pde

class Mover {
PVector location;
PVector velocity;
PVector gravity=new PVector(0,9.8);
Mover() {
location = new PVector(width/2, height/2);
velocity = new PVector(1, 1);
}
void update() {
location.add(velocity);
location.add(gravity);
}
void display() {
stroke(0);
strokeWeight(2);
fill(127);
ellipse(location.x, location.y, 48, 48);
}
void checkEdges() {
if (location.x > width || location.x < 0) {
velocity.x*=-1;
}
if (location.y > height || location.y < 0) {
velocity.y*=-1;
}
}
}

Event Timeline