class SpeedButtons{ float r; float g; float blu; float r2; float g2; float blu2; float speed = 4; boolean mouseOverSlower; boolean mouseOverFaster; float x = (GRID_SPACE * 7); float y = (GRID_SPACE); float btnWidth = (GRID_SPACE * 3); float btnHeight = ((GRID_SPACE * 2)/3); //constructor SpeedButtons(){ } void display(){ rollOverColor(); fill(r,g,blu); stroke(255); strokeWeight(3); rect(x, y, (GRID_SPACE * 3),((GRID_SPACE * 2)/3)); fill(r2,g2,blu2); rect((width - (x + (GRID_SPACE * 3))), y, (GRID_SPACE * 3),((GRID_SPACE * 2)/3)); showText(); } void rollOverColor(){ if(mouseOverFaster()){ r = 255; g = 143; blu = 5; r2 = 34; g2 = 48; blu2 = 188; } else if(mouseOverSlower()){ r = 34; g = 48; blu = 188; r2 = 255; g2 = 143; blu2 = 5; } else{ r = 34; g = 48; blu = 188; r2 = 34; g2 = 48; blu2 = 188; } } boolean mouseOverFaster(){ if((mouseX > x) && (mouseX < (x + btnWidth)) && (mouseY > y) && (mouseY < (y + btnHeight))){ return true; } else { return false; } } boolean mouseOverSlower(){ if((mouseX > (width - (x + btnWidth))) && (mouseX < (width - x)) && (mouseY > y) && (mouseY < (y + btnHeight))){ return true; } else { return false; } } void mousePressed(){ if(mouseOverFaster()){ speed = speed * 1.5; } if (mouseOverSlower()){ speed = ((speed * 2)/3); } } void showText(){ textFont(OCR); fill(255); textAlign(CENTER); text("Faster", (x + (GRID_SPACE * 1.5)), (y +GRID_SPACE/2)); text("Slower", ((width - (x + (GRID_SPACE * 3))) + (GRID_SPACE * 1.5)), (y +GRID_SPACE/2)); } }