class Led { //member variablen float _x, _y, _radius; int _id; color _col; // Constructor Led(float x, float y, float radius, int id) { _x = x - radius; _y = y - radius; _id = id; _radius = radius; } float x() { return _x; } float y() { return _y; } int getID() { return _id; } void setColor(color col) { _col = col; } color getColor() { return _col; } void displayLed() { ellipseMode(RADIUS); fill(_col); stroke(255); strokeWeight(5); ellipse( _x, _y, _radius, _radius); displayText(); } void displayText() { int fontSize = 12; textAlign(CENTER, CENTER); fill(255); textSize(fontSize); text(_id, _x, _y); } boolean mouseOverLed() { float disX = _x - mouseX; float disY = _y - mouseY; if (sqrt(sq(disX) + sq(disY)) < _radius) { return true; } else { return false; } } boolean shapeOverLed (int x1, int y1, int d1, int x2, int y2, int d2) { // find distance between the two objects float xDist = x1-x2; // distance horiz float yDist = y1-y2; // distance vert float distance = sqrt((xDist*xDist) + (yDist*yDist)); // diagonal distance // test for collision if (d1/2 + d2/2 > distance) { return true; // if a hit, return true } else { // if not, return false return false; } } }