// A class to describe a thing in our world // Has variables location, velocity and acceleration class Moo { Vector3D loc; Vector3D vel; Vector3D acc; private float maxvel; // The constructor (called when the object is first created) Moo(Vector3D a, Vector3D v, Vector3D l) { acc = a; vel = v; loc = l; maxvel = 7; } Vector3D getAcc() { return acc; } Vector3D getVel() { return vel; } Vector3D getLoc() { return loc; } void setLoc(Vector3D v) { loc = v; } void setVel(Vector3D v) { vel = v; } void setAcc(Vector3D v) { acc = v; } // main function to operate object void go(float c) { update(); borders(); render(c); } // function to update location void update() { vel.add(acc); loc.add(vel); // limit speed to max vel.limit(maxvel); /* if (vel.magnitude() > maxvel) { vel.normalize(); vel.mult(maxvel); }*/ } void borders() { if((loc.y() > height) || (loc.y() < 0)) { vel.setY(-vel.y()); } if((loc.x() > width) || (loc.x() < 0)) { vel.setX(-vel.x()); } } // function to display void render(float c) { noStroke(); fill(0,200,c); rect(loc.x(), loc.y(), 5,5); } }