This is an old revision of the document!
Joann's crazyDog.js
let x = 0;
let y = 0;
let dim = 0.0;
function setup() {
createCanvas(1800, 780);
}
class dog{
constructor(x,n,color)
{ this.positionX =x;
this.dogNumber =n;
this.dogColor =color;
}
draw (){
//body
fill(color(this.dogColor))
ellipse(this.positionX+88,340,80,50);
//legs
rect(this.positionX+100, 360, 13, 40);
rect(this.positionX+66, 360, 13, 40);
//ears
fill(random(0,255), random(0,255), random(0,255))
circle(this.positionX+70,270,30);
circle(this.positionX+28,270,30);
//head
fill(color(this.dogColor))
circle(this.positionX+50,300,60 );
//black eyes
fill(0,0,0)
circle(this.positionX+60,299,20);
circle(this.positionX+36,300,15);
//white eyes
fill(255,255,255)
circle(this.positionX+58,300,8);
circle(this.positionX+34,300,8);
//mouth
fill(232, 60, 63)
arc(this.positionX+47, 312, 40, 30, 0, PI ,PIE,10);
//tail
fill(random(0,255), random(0,255), random(0,255))
circle(this.positionX+137,338,20);
}
}
function dogArray (n) {
let outputArray = [];
for (let i = 0; i < n ; i++) {
outputArray.push(new dog(20 + (i*120),100, "pink"))
}
return outputArray
}
let myDog = dogArray(25);
class patternA{
constructor(x,n)
{this.positionx =x;
this.patternNumber =n;
}
draw(){
fill(196, 184, 245)
square(this.positionx+10,400 ,100);
}
}
function patternAArray (n) {
let outputArray = [];
for (let i = 0; i < n ; i++) {
outputArray.push(new patternA(10 + (i*60),100))
}
return outputArray
}
let myPatternA = patternAArray(30);
class patternB{
constructor(x,n)
{this.positionx =x;
this.patternNumber =n;
}
draw(){
fill(133, 117, 255)
circle(this.positionx+30, 430, 20);
}
}
function patternBArray (n) {
let outputArray = [];
for (let i = 0; i < n ; i++) {
outputArray.push(new patternB(10 + (i*60),100))
}
return outputArray
}
let myPatternB = patternBArray(30);
class sun{
constructor(x,y,n,c)
{this.positionx =x;
this.positiony =y;
this.sunNumber =n;
this.sunColor =c;
}
draw(){
fill(color(this.sunColor))
circle(this.positionx+40,this.positiony+40,60)
}
}
class grass{
constructor(x,y,n)
{this.x=x;
this.y=y;
this.n=n;
}
draw(){
fill(50, 161, 47)
rect(this.x-19, 500,2025, 55);
}
}
class greenThing{
constructor(x,y,n)
{this.x=x;
this.y=y;
this.n=n;
}
draw(){
fill(62, 201, 58)
triangle(this.x+50, this.y+520, 78, 465, 106, 520);
triangle(this.x+70, this.y+520, 108, 465, 116, 520);
triangle(this.x+88, this.y+520, 158, 465, 146, 520);
triangle(this.x+400, this.y+500, 428, 445, 456, 520);
triangle(this.x+440, this.y+500, 478, 445, 486, 500);
fill(12, 201, 107)
triangle(this.x+88, this.y+520, 158, 465, 146, 520);
triangle(this.x+388, this.y+520, 458, 465, 446, 520);
fill(26, 120, 7)
triangle(this.x+100, this.y+520, 200, 555, 226, 520);
}
}
function draw() {
background(255, 254, 212);
for (let i = 0; i < myPatternA.length ; i++){
myPatternA[i].draw()}
for (let i = 0; i < myPatternB.length ; i++){
myPatternB[i].draw()}
let Grass1 =new grass(30,60,1)
Grass1.draw()
let GreenThing1 =new greenThing(20,10,1)
GreenThing1.draw()
let Sun1 =new sun(20,20,1,"yellow")
Sun1.draw()
x = x-2
if (x > width + dim) {
x = dim;
}
translate(x, dim);
for (let i = 0; i < myDog.length ; i++){
myDog[i].draw()}
}