class JakeButton { PImage overbutton; PImage clickbutton; PImage basebutton; int xloc, yloc; int bwidth, bheight; boolean over; boolean clicked; boolean visible; boolean locked; JakeButton(int x, int y, PImage over, PImage click, PImage base) { xloc = x; yloc = y; overbutton = over; clickbutton = click; basebutton = base; bwidth = overbutton.width; bheight = overbutton.height; clicked = false; visible = true; locked = false; } void setVisible(boolean state) { visible = state; } boolean overButton() { if ((mouseX >= xloc) && (mouseX <= (xloc + bwidth)) && (mouseY >= yloc) && (mouseY <= (yloc + bheight))) { return true; } else { return false; } } void updateButton() { if (visible) { over = overButton(); boolean mouseValue = mousePressed; boolean tempclick = mouseValue & over; clicked = false; if (tempclick & !locked) { clicked = true; locked = true; } if(!mouseValue) locked = false; } else { clicked = false; locked = false; over = false; } } void drawButton() { if (visible) { if (over) { if (clicked) { image(clickbutton,xloc,yloc); } else { image(overbutton,xloc,yloc); } } else { image(basebutton,xloc,yloc); } } } }