Brendan Hsu's crazyDog.js
about my crazyDog.js
我覺得我的狗狗做得很好因為這個是我第一次做
I think my dog is doing very well because this is my first time doing programming.
The animation code is released under the GNU Lesser General Public License v2.1
the code for my crazyDog.js
function setup() { createCanvas(2800, 700 ); } class Dog { constructor (xposition, yposition, size,dColor, dPosition) { this.xposition = xposition; this.yposition = yposition; this.dogSize = size; this .dogColor = dColor; this.dogPosition = dPosition; } draw () { translate(this.positionX+50, this.yposition+50) stroke(255, 0, 0); fill(Math.random()*255,Math.random()*255,Math.random()*255); for(let i = 0; i<1; i++){ circle(this.xposition+90,90+this.yposition, 40);} fill(Math.random()*255,Math.random()*255,Math.random()*255); rect(this.xposition+100, 100+this.yposition,90, 60); fill(Math.random()*255,Math.random()*255,Math.random()*255); rect(this.xposition+100,160+this.yposition, 30, 30); fill(Math.random()*255,Math.random()*255,Math.random()*255); rect(this.xposition+160,160+this.yposition, 30, 30); fill(Math.random()*255,Math.random()*255,Math.random()*255); ellipse(this.xposition+190,90+this.yposition, 20, 50); fill(Math.random()*255,Math.random()*255,Math.random()*255); circle(this.xposition+83,80+this.yposition, 10); fill(Math.random()*255,Math.random()*255,Math.random()*255); circle(this.xposition+99,80+this.yposition, 10); } } class Background { constructor (xposition, size, bColor, bposition,yposition) { this.xposition = xposition; this.backgroundSize = size; this.backgroundColor = bColor; this.backgroundposition = bposition; this.yposition=yposition } draw () { fill(color("beige")) fill(Math.random()*355,Math.random()*355,Math.random()*325); rect(this.xposition+30,20+this.yposition,250,250); fill(Math.random()*355,Math.random()*355,Math.random()*325); rect(this.xposition+40,30+this.yposition,230,230); } } function dogArray (n) { let outputArray = []; for (let i = 0; i < n ; i++) { outputArray.push(new Dog (25 + (i*300), 20 ,200, 1000, 1000)) } return outputArray } function dogArrays (n) { let outputArray2 = []; for (let i = 0; i < n ; i++) { outputArray2.push(new Dog (25 + (i*300), 300 ,200, 1000, 1000)) } return outputArray2 } function backgroundArray (n) { let outputArray = []; for (let i = 0; i < n ; i++) { outputArray.push(new Background (20 + (i*300),100, 1000, 1000,20)) } return outputArray } function backgroundArrays (n) { let outputArrays = []; for (let i = 0; i < n ; i++) { outputArrays.push(new Background (20 + (i*300),100, 1000, 1000,300)) } return outputArrays } function draw() { background(220); for(let i = 0; i < 10 ; i++){ let myDogs = dogArray(10); let mydogss= dogArrays(10); let myBackgrounds = backgroundArray(10); let myBackgroundss = backgroundArrays(10); for(let i = 0; i < myBackgrounds.length ; i++){ myBackgrounds[i].draw() } for(let i = 0; i < myBackgroundss.length ; i++){ myBackgroundss[i].draw() } for(let i = 0; i < myDogs.length ; i++){ myDogs[i].draw(); } for(let i = 0; i < mydogss.length ; i++){ mydogss[i].draw(); } } }