/* Obstacles in this example are quite simple, just a rectangle that can draw itself to screen, and test to see if an object is intersecting it. */ class Obstacle { Rectangle r; /* Create a new obstacle with top left corner at (x, y) with width (w) and height (h) */ Obstacle(int x, int y, int w, int h) { r = new Rectangle(x, y, w, h); } Obstacle(float x, float y, float w, float h) { // calculate the size based upon percentage of the screen r = new Rectangle(int(x * width), int(y * height), int(w * width), int(h * height)); } void render() { // draw the rectangle to screen noStroke(); fill(100); rect(r.x, r.y, r.width, r.height); } boolean contains(Vector3D loc) { if (r.contains( (int)loc.getX(), (int)loc.getY())) { return true; } else { return false; } } }