Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| oliver-wang-generative [2021/06/25 03:14] – oliver.wang | oliver-wang-generative [2021/06/29 01:39] (current) – renick | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| Line 9: | Line 9: | ||
| 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 " | 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 ===== | ===== the code for my crazyDog.js ===== | ||
| Line 14: | Line 16: | ||
| < | < | ||
| function setup() { | function setup() { | ||
| - | | + | createCanvas(1800, |
| - | + | x = width; | |
| + | y = height / 2; | ||
| } | } | ||
| Line 30: | Line 33: | ||
| //sun | //sun | ||
| - | //go left | ||
| - | if (keyIsDown(LEFT_ARROW)) { | ||
| - | movingX -= 5; | ||
| - | movingY += 5; | ||
| - | |||
| - | if(movingY> | ||
| - | movingY-=5; | ||
| - | } | ||
| - | } | ||
| - | //go right | ||
| - | if (keyIsDown(RIGHT_ARROW)) { | ||
| - | x += 5; | ||
| - | } | ||
| fill(' | fill(' | ||
| noStroke(0) | noStroke(0) | ||
| Line 52: | Line 42: | ||
| noStroke() | noStroke() | ||
| fill(103, 222, 103) | fill(103, 222, 103) | ||
| - | rect(positionX, | + | rect(positionX, |
| positionX += 200 | positionX += 200 | ||
| } | } | ||
| Line 144: | Line 134: | ||
| fill(' | fill(' | ||
| //cloud | //cloud | ||
| - | ellipse(this.positionX, | + | ellipse(x+this.positionX, |
| - | rect(this.positionX-10, | + | rect(x+this.positionX-10, |
| - | rect(this.positionX-30, | + | rect(x+this.positionX-30, |
| - | ellipse(positionX*i, 49, 50, 30) | + | ellipse(x+positionX+4, 49, 50, 30) |
| this.positionX = this.positionX + 200 | this.positionX = this.positionX + 200 | ||
| } | } | ||
| } | } | ||
| - | } | ||
| - | |||
| - | function backgroundArray (numberOfBackground){ | ||
| - | var dogBackgroundArray = []; | ||
| - | for(let i = 0; i < numberOfBackground; | ||
| - | dogBackgroundArray.push(new DogBackground(100, | ||
| - | } | ||
| - | return dogBackgroundArray | ||
| - | } | ||
| - | function randomArray (numberOfHi){ | ||
| - | var myColorArray = [] | ||
| - | for(let i = 0; i < numberOfHi; i++){ | ||
| - | myColorArray.push (Math.random()*255) | ||
| - | } | ||
| - | } | ||
| - | function pinkDogArray(numberOfDog){ | ||
| - | var DogsArray = [] | ||
| - | for(let i = 0; i < numberOfDog; | ||
| - | DogsArray.push(new Dog(0, 100, Math.random()*255, | ||
| - | } | ||
| - | return DogsArray | ||
| - | } | ||
| - | |||
| - | function cloudArray (n){ | ||
| - | var myCloudArray = [] | ||
| - | for(let i = 0; i < n; i++){ | ||
| - | myCloudArray.push(new Cloud(100, 100)) | ||
| - | } | ||
| - | return myCloudArray | ||
| - | } | ||
| - | |||
| - | |||
| - | function draw() { | ||
| - | background(161, | ||
| - | | ||
| - | let myCloudsArray = cloudArray(1) | ||
| - | console.log(myCloudsArray) | ||
| - | let myBackgroundArray = backgroundArray(1) | ||
| - | console.log(myBackgroundArray) | ||
| - | let myPinkDogArray = pinkDogArray(1) | ||
| - | console.log(myPinkDogArray) | ||
| - | |||
| - | | ||
| - | | ||
| - | myBackgroundArray[i].draw() | ||
| - | } | ||
| - | | ||
| - | for(let i = 0; i < myCloudsArray.length; | ||
| - | |||
| - | myCloudsArray[i].draw() | ||
| - | } | ||
| - | |||
| - | | ||
| - | for(let i = 0; i < myPinkDogArray.length; | ||
| - | |||
| - | myPinkDogArray[i].draw() | ||
| - | } | ||
| - | |||
| - | |||
| - | |||
| - | |||
| } | } | ||
| </ | </ | ||