Guest User

Untitled

a guest
Oct 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. class Paw {
  2. constructor(x, y, xspeed, yspeed) {
  3. this.x = x;
  4. this.y = y;
  5. this.xspeed = xspeed;
  6. this.yspeed = yspeed;
  7. this.touch=false;
  8. this.bad=false;
  9. }
  10.  
  11. //orange & stripe
  12. displayOrange() {
  13. fill(255, 138, 49);
  14. noStroke();
  15. rectMode(CENTER);
  16. rect(this.x, this.y, 70, 150, 40);
  17. fill(255, 224, 138);
  18. rect(this.x, this.y-20, 70, 10);
  19. fill(255, 224, 138);
  20. rect(this.x, this.y+10, 70, 10);
  21. fill(0);
  22. rect(this.x, this.y-65, 3, 20, 40);
  23. fill(0);
  24. rect(this.x+10, this.y-64, 3, 18, 40);
  25. fill(0);
  26. rect(this.x-10, this.y-64, 3, 18, 40);
  27. }
  28.  
  29. // grey and dots
  30. displayGrey(){
  31. fill(158, 155, 146);
  32. noStroke();
  33. rectMode(CENTER);
  34. rect(this.x+80, this.y, 70, 150, 40);
  35. fill(255, 255, 255);
  36. ellipse(this.x+65, this.y-10, 25, 25);
  37. fill(255, 219, 101);
  38. ellipse(this.x+100, this.y-30, 15, 15);
  39. fill(115, 101, 95);
  40. ellipse(this.x+80, this.y-40, 10, 10);
  41. fill(0);
  42. rect(this.x+80, this.y-65, 3, 20, 40);
  43. fill(0);
  44. rect(this.x+90, this.y-64, 3, 18, 40);
  45. fill(0);
  46. rect(this.x+70, this.y-64, 3, 18, 40);
  47. }
  48.  
  49. move(){
  50. this.xspeed = reach(this.x, this.xspeed, 0, width);
  51. this.x += this.xspeed;
  52.  
  53. this.yspeed = reach(this.y, this.yspeed, height-30, height);
  54. this.y += this.yspeed;
  55. }
  56.  
  57. touch(){
  58. this.touch = this.y < height/2 +20
  59. if (this.touch) {
  60. this.bad = ! this.bad;
  61. }
  62. return this.touch;
  63. }
  64.  
  65. isBad(){
  66. if (this.bad){
  67. fill(0);
  68. textSize(50);
  69. text("BAD CAT", 10, 50);
  70. }
  71. else {
  72. this.bad=false;
  73. }
  74. }
  75.  
  76. }
Add Comment
Please, Sign In to add comment