Table of Contents

Larissa Kuo's crazyDog.js

by Larissa

about my CrazyDog.js

My dog is supposed to look like a teddy bear, but instead, it looks like a real bear instead of a cute teddy bear. But my dog does shine in different colors, and it does let your eyes catch it. I had some difficulty during the process of my dog, but at last, I got to finish my dog at the right time. My dog moves up and pretty smoothly, I hope my dog lets you have a bright and warm time after you see it.

The animation code is released under the GNU Lesser General Public License v2.1.

the code for my crazyDog.js

function setup() {
  createCanvas(1800, 780)

}
class BackgroundPattern {
  constructor (xposition, yposition, cSize, sSize, cColor, sColor)
  { this.xposition = xposition;
    this.yposition = yposition;
    this.circleSize = cSize;
    this.squareSize = sSize;
    this.circleColor = cColor;
    this.squareColor = sColor
  }
  draw () {
    fill(this.circleColor);
    circle(this.xposition+100,this.yposition+100,this.circleSize);
    fill(this.squareColor);
    square(this.xposition+80,this.yposition+100,this.squareSize);
    square(this.xposition+120,this.yposition+100,this.squareSize);
  }
}
 
class Dog {
  constructor (xposition,yposition) {
  this.xposition = xposition;
  this.yposition = yposition;
}
  draw (){
  //ears1
 fill(Math.random() * 255,Math.random()* 255,Math.random() * 225)
circle(this.xposition+130, this.yposition+90, 80);
 
 //ear2
  fill (Math.random() * 255,Math.random()* 255,Math.random() * 225 )
circle(this.xposition+255, this.yposition+80, 80);
 
 //earing1
 fill( 255,255, 225)
circle(this.xposition+140, this.yposition+90, 25);
 
  //earing2
  fill(Math.random() )
circle(this.xposition+250,this.yposition+80,25);
 
   //body
  fill(Math.random() * 255,Math.random() * 255,Math.random() * 225)
ellipse(this.xposition+205, this.yposition+300, 150, 170);
 
//hands
ellipse(this.xposition+205, this.yposition+300, 15, 15);
 
 //head
   fill (255, 255, 255 )
circle(this.xposition+200, this.yposition+140, 155);
 
 //eyes1
 fill(Math.random() * 255,Math.random() * 255,Math.random() * 225)
circle(this.xposition+170, this.yposition+135, 50);
 
 //eyes2
   fill(Math.random() * 255,Math.random() * 255,Math.random() * 225)
circle(this.xposition+230, this.yposition+135, 50);
 
 //mouth1
   fill (Math.random() )
circle(this.xposition+170,this.yposition+140, 10);
 
  //mouth2
  fill(Math.random() )
circle(this.xposition+230,this.yposition+140,10);
 
  //mouth3
  fill(Math.random() )
circle(this.xpositio+200,this.yposition+190,40);
 
  //hand1
  fill(255,255,255 )
circle(this.xposition+140,this.yposition+250,40);
 
  //hand2
  fill(255,255,255 )
circle(this.xposition+270,this.yposition+250,40);
 
  //leg1
  fill(255,255,255 )
circle(this.xposition+230,this.yposition+140,20);
 
  //leg2
  fill(255,255,255 )
circle(this.xposition+140,this.yposition+350,60);
 
  //leg3
  fill(Math.random() * 255,Math.random() * 255,Math.random() * 225)
circle(this.xposition+260,this.yposition+350,60);
  }
}
 
function backgroundPatternArray (n, y) {
    let outputArray = [];
    for (let i = 0; i < n ; i++) {
        outputArray.push(new BackgroundPattern (20 + (i*120),0 + y,50, 10,"pink", "light blue"))
    }
    return outputArray
}
 
function dogArray (n, y) {
    let outputArray = [];
    for (let i = 0; i < n ; i++) {
        outputArray.push(new Dog (20 + (i*120),100+y))
    }
    return outputArray
}
 
 

function draw() {
  background(217, 255, 253);
  //let square2 = new BackgroundPattern (200,0,100, 30,"light blue", "pink");
  //square2.draw();
  for(let i = 0; i < 10 ; i++){
      let myBackgroundPattern = backgroundPatternArray(25,0 + (i * 100));
      for(let i = 0; i < myBackgroundPattern.length ; i++){
        myBackgroundPattern[i].draw()
      }
  }  
  y =   (height * (1/2)) + (Math.sin(frameCount/10) * (height/5))
  let myDogs = dogArray(25, y);
  for(let i = 0; i < myDogs.length ; i++){
    myDogs[i].draw()
  }
   
}

Click here to adopt! Adopt Our Dog