class Button { float x = 0; float y = 0; float w = 0; float h = 0; String label = ""; PFont font; float points = 32; int align = CENTER; Button(String iLab, PFont iFont, float ix, float iy, float iw, float ih) { font = iFont; label = iLab; x = ix; y = iy; w = iw; h = ih; } void display() { textAlign(align); fill(255); textFont(font, points); switch(align) { case LEFT: text(label, x, y + h / 2); break; case CENTER: text(label, x + w / 2, y + h / 2); break; case RIGHT: text(label, x + w, y + h / 2); break; } } boolean hit() { return (mouseX >= x && mouseX <= x + w && mouseY >= y && mouseY <= y + h); } }