NOC : Assignment 9 – Ji Hwan Shin

Link: https://editor.p5js.org/jihwanshin96/sketches/NI2MfiOT4

For this assignment I utilized the concepts of inheritance and polymorphism that we learned in class to create a humorous sketch inspired by the song “It’s Raining Men” by the Weather Girls. I created a class of ‘man’ and an inheritance class of ‘man2’ which contains the attributes of the former class. By doing this, I didn’t have to repeat any of the parameters or movements of the former object class. To make things more interesting I replaced the shapes with actual images and called the music/images in setup.

class Man {
constructor(pos) {
this.pos = pos.copy();
this.vel = createVector(random(-2,3),random(-5,5));
this.acc = createVector();
this.size = random(10,20);
this.lifespan = 1.0;
this.lifeDecrease = random(0.01, 0.005);
this.isDone = false;
}
update() {
this.vel.add(this.acc);
this.pos.add(this.vel);
this.acc.mult(0);

// dying
this.lifespan -= this.lifeDecrease;
if (this.lifespan < 0) {
this.lifespan = 0;
this.isDone = true;
}
}
display() {
push();
translate(this.pos.x, this.pos.y);
noStroke();
image(img2, 0, 0, img2.width/7, img2.height/7);
pop();
}
}

Leave a Reply