public class Button { int x, y; int xsize; int ysize; boolean over = false; boolean pressed = false; PImage ostrich_but; PImage ostrich_but_roll; PImage flam_but; PImage flam_but_roll; PImage turkey_but; PImage turkey_but_roll; PImage woody_but; PImage woody_but_roll; PImage owl_but; PImage owl_but_roll; PImage loon_but; PImage loon_but_roll; PImage gull_but; PImage gull_but_roll; int stretch = 0; //set to 0 for standard def video, 700 for 1440 Button(int xp, int yp, int xs, int ys) { x = xp + stretch; y = yp; xsize = xs; ysize = ys; } void loadButtons(String a) { if (a == "ostrich") { ostrich_but = loadImage("ostrich_but.jpg"); ostrich_but_roll = loadImage("ostrich_but_roll.jpg"); } else if (a == "flamingo") { flam_but = loadImage("flam_but.jpg"); flam_but_roll = loadImage("flam_but_roll.jpg"); } else if (a == "turkey") { turkey_but = loadImage("turkey_but.jpg"); turkey_but_roll = loadImage("turkey_but_roll.jpg"); } else if (a == "wood") { woody_but = loadImage("woody_but.jpg"); woody_but_roll = loadImage("woody_but_roll.jpg"); } else if (a == "owl") { owl_but = loadImage("owl_but.jpg"); owl_but_roll = loadImage("owl_but_roll.jpg"); } else if (a == "loon") { loon_but = loadImage("loon_but.jpg"); loon_but_roll = loadImage("loon_but_roll.jpg"); } else if (a == "gull") { gull_but = loadImage("gull_but.jpg"); gull_but_roll = loadImage("gull_but_roll.jpg"); } } //Updates the feild every frame void update() { if ((mouseX >= x) && (mouseX <= x+xsize) && (mouseY >= y) && (mouseY <= y+ysize)) { over = true; } else { over = false; } } boolean press() { if (over == true) { pressed = true; return true; } else { return false; } } void release() { pressed = false; //set to false when the mouse is released } void display(String a) { if (a == "ostrich") { if (over == true){ image(ostrich_but_roll, stretch+486, 279); } else { image(ostrich_but, stretch+486, 279); } } else if (a == "flamingo") { if (over == true){ image(flam_but_roll, stretch+595, 279); } else { image(flam_but, stretch+595, 279); } } else if (a == "turkey") { if (over == true){ image(turkey_but_roll, stretch+423, 319); } else { image(turkey_but, stretch+423, 319); } } else if (a == "wood") { if (over == true){ image(woody_but_roll, stretch+187, 319); } else { image(woody_but, stretch+187, 319); } } else if (a == "gull") { if (over == true){ image(gull_but_roll, stretch+300, 319); } else { image(gull_but, stretch+300, 319); } } else if (a == "loon") { if (over == true){ image(loon_but_roll, stretch+357, 319); } else { image(loon_but, stretch+357, 319); } } else if (a == "owl") { if (over == true){ image(owl_but_roll, stretch+236, 319); } else { image(owl_but, stretch+236, 319); } } } }