Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Paw {
- constructor(x, y, xspeed, yspeed) {
- this.x = x;
- this.y = y;
- this.xspeed = xspeed;
- this.yspeed = yspeed;
- this.touch=false;
- this.bad=false;
- }
- //orange & stripe
- displayOrange() {
- fill(255, 138, 49);
- noStroke();
- rectMode(CENTER);
- rect(this.x, this.y, 70, 150, 40);
- fill(255, 224, 138);
- rect(this.x, this.y-20, 70, 10);
- fill(255, 224, 138);
- rect(this.x, this.y+10, 70, 10);
- fill(0);
- rect(this.x, this.y-65, 3, 20, 40);
- fill(0);
- rect(this.x+10, this.y-64, 3, 18, 40);
- fill(0);
- rect(this.x-10, this.y-64, 3, 18, 40);
- }
- // grey and dots
- displayGrey(){
- fill(158, 155, 146);
- noStroke();
- rectMode(CENTER);
- rect(this.x+80, this.y, 70, 150, 40);
- fill(255, 255, 255);
- ellipse(this.x+65, this.y-10, 25, 25);
- fill(255, 219, 101);
- ellipse(this.x+100, this.y-30, 15, 15);
- fill(115, 101, 95);
- ellipse(this.x+80, this.y-40, 10, 10);
- fill(0);
- rect(this.x+80, this.y-65, 3, 20, 40);
- fill(0);
- rect(this.x+90, this.y-64, 3, 18, 40);
- fill(0);
- rect(this.x+70, this.y-64, 3, 18, 40);
- }
- move(){
- this.xspeed = reach(this.x, this.xspeed, 0, width);
- this.x += this.xspeed;
- this.yspeed = reach(this.y, this.yspeed, height-30, height);
- this.y += this.yspeed;
- }
- touch(){
- this.touch = this.y < height/2 +20
- if (this.touch) {
- this.bad = ! this.bad;
- }
- return this.touch;
- }
- isBad(){
- if (this.bad){
- fill(0);
- textSize(50);
- text("BAD CAT", 10, 50);
- }
- else {
- this.bad=false;
- }
- }
- }
Add Comment
Please, Sign In to add comment