Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| oliver-wang-generative [2021/06/20 18:22] – created oliver.wang | oliver-wang-generative [2021/06/29 01:39] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ========Oliver Wang's crazyDog.js======== | ||
| + | by [[oliver-wang|Oliver]] | ||
| + | |||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| + | |||
| + | ===== about my crazyDog.js ===== | ||
| + | |||
| + | I think my dog code is very different with other, cause I want to have a good score of program dog, so I think a lot and type a lot of code. My dog is different with other is because they just use triangle, square, circle, and I use a code name is " | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| + | < | ||
| + | function setup() { | ||
| + | createCanvas(1800, | ||
| + | x = width; | ||
| + | y = height / 2; | ||
| + | } | ||
| + | |||
| + | class DogBackground{ | ||
| + | constructor(y, | ||
| + | this.positionY = y; | ||
| + | this.numberDog = numberOfDog | ||
| + | }draw(){ | ||
| + | let x = 0; | ||
| + | let X = x; | ||
| + | let positionX = x; | ||
| + | let movingX = 100; | ||
| + | let movingY = 100; | ||
| + | //sun | ||
| + | |||
| + | fill(' | ||
| + | noStroke(0) | ||
| + | circle(398, this.positionY-100, | ||
| + | //sky | ||
| + | |||
| + | for(let i = 0; i < this.numberDog+10 ; i++){ | ||
| + | //grass | ||
| + | noStroke() | ||
| + | fill(103, 222, 103) | ||
| + | rect(positionX, | ||
| + | positionX += 200 | ||
| + | } | ||
| + | |||
| + | //tree | ||
| + | for(let i =0; i < | ||
| + | x += 200 | ||
| + | fill(120, 74, 0) | ||
| + | rect(x-77, this.positionY+100, | ||
| + | triangle(x-75, | ||
| + | triangle(x-70, | ||
| + | fill(' | ||
| + | ellipse(x-62, | ||
| + | x += 60 | ||
| + | } | ||
| + | |||
| + | for(let i = 0 ; i < this.numberDog+1; | ||
| + | |||
| + | fill(246, 98, 135) | ||
| + | circle(x-118, | ||
| + | circle(x-121, | ||
| + | circle(x-104, | ||
| + | circle(x-112, | ||
| + | circle(x-102, | ||
| + | fill(' | ||
| + | circle(x-111, | ||
| + | x -= 290 | ||
| + | }}} | ||
| + | |||
| + | class Dog { | ||
| + | constructor(x, | ||
| + | this.DogColor1 = colorOfDog1; | ||
| + | this.DogColor2 = colorOfDog2; | ||
| + | this.DogColor3 = colorOfDog3; | ||
| + | this.positionX = x; | ||
| + | this.positionY = y; | ||
| + | this.numberDog = numberOfDog; | ||
| + | this.dogSpace = space; | ||
| + | }draw (){ | ||
| + | for(let i = 0; i < this.numberDog; | ||
| + | noStroke() | ||
| + | //body | ||
| + | fill(Math.random()*255, | ||
| + | rect(this.positionX-3, | ||
| + | //feet | ||
| + | rect(this.positionX+30, | ||
| + | rect(this.positionX+82, | ||
| + | rect(this.positionX+19, | ||
| + | |||
| + | //head | ||
| + | rect(this.positionX+116, | ||
| + | //mouth | ||
| + | rect(this.positionX+138, | ||
| + | |||
| + | stroke(1) | ||
| + | noFill() | ||
| + | curve(this.positionX+23, | ||
| + | curve(this.positionX+207, | ||
| + | curve(this.positionX+73, | ||
| + | curve(this.positionX+44, | ||
| + | curve(this.positionX+48, | ||
| + | curve(this.positionX+202, | ||
| + | curve(this.positionX+138, | ||
| + | curve(this.positionX+79, | ||
| + | curve(this.positionX+92, | ||
| + | curve(this.positionX+142 | ||
| + | line(this.positionX+158, | ||
| + | line(this.positionX+28, | ||
| + | line(this.positionX+85, | ||
| + | //eye | ||
| + | fill(' | ||
| + | circle(this.positionX+142, | ||
| + | //ear | ||
| + | ellipse(this.positionX+127, | ||
| + | //nose | ||
| + | square(this.positionX+158, | ||
| + | fill(Math.random()*255, | ||
| + | noStroke() | ||
| + | stroke(1) | ||
| + | curve(this.positionX+24, | ||
| + | this.positionX = this.positionX + this.dogSpace | ||
| + | }}} | ||
| + | class Cloud{ | ||
| + | constructor(x, | ||
| + | this.positionX = x; | ||
| + | this.positionY = y; | ||
| + | }draw(){ | ||
| + | let positionX = this.positionX | ||
| + | for(let i = 0; i < 10; i++){ | ||
| + | noStroke() | ||
| + | fill(' | ||
| + | //cloud | ||
| + | ellipse(x+this.positionX, | ||
| + | rect(x+this.positionX-10, | ||
| + | rect(x+this.positionX-30, | ||
| + | ellipse(x+positionX+4, | ||
| + | this.positionX = this.positionX + 200 | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||