Guest User

Untitled

a guest
Jan 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class Button {
  2.  
  3. int x,y;
  4. int w, h;
  5. boolean clicked;
  6.  
  7. public Button(int x, int y){
  8. this.x = x;
  9. this.y = y;
  10. this.w = 100;
  11. this.h = 30;
  12. clicked = false;
  13. }
  14.  
  15. public void draw(){
  16. if (clicked) {
  17. fill(255);
  18. } else {
  19. fill(127);
  20. }
  21. stroke(0);
  22. rect(x,y, w,h);
  23. }
  24.  
  25. public void clicked(){
  26. if (mouseX >= x && mouseX <= x+w && mouseY >= y && mouseY <= y+h) {
  27. clicked = !clicked;
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment