xxxxxxxxxx
107
//Vivianna Mo
//Code! 1 Fall Semester
//Assignment 2 - Kirby in the Ocean
function setup() {
createCanvas(600, 500);
}
function draw() {
background(56, 2, 107);
stars();
moon();
wave(0, 500);
}
function stars() {
noStroke();
for (i = 0; i < 50; i++) {
let x = random(10, 590);
let y = random(10, 350);
fill(253, 255, 209);
ellipse(x, y, 4);
}
noLoop();
}
function moon() { // from the p5.js reference https://p5js.org/reference/#/p5/bezierVertex
fill(250, 250, 250);
push();
translate(150, 200);
scale(2, 2);
rotate(85);
beginShape();
vertex(30, 20);
bezierVertex(80, 20, 80, 75, 30, 75);
bezierVertex(50, 75, 70, 35, 30, 20);
endShape();
pop();
}
function wave(x, y) { //x = 0, y = 500
fill(55, 107, 250);
beginShape();
curveVertex(x, y);
curveVertex(x, y - 100);
curveVertex(x + 50, y - 70);
curveVertex(x + 50, y - 100);
curveVertex(x + 100, y - 70);
curveVertex(x + 150, y - 100);
curveVertex(x + 200, y - 70);
curveVertex(x + 250, y - 100);
curveVertex(x + 300, y - 70);
curveVertex(x + 350, y - 100);
curveVertex(x + 400, y - 70);
curveVertex(x + 450, y - 100);
curveVertex(x + 500, y - 70);
curveVertex(x + 550, y - 100);
curveVertex(x + 600, y - 70);
curveVertex(x + 600, y);
endShape(CLOSE);
}
function mousePressed() {
kirby();
}
function kirby() {
//feet
fill(245, 59, 111);
ellipse(150, 390, 120, 90);
ellipse(345, 390, 120, 90);
//body + arms
fill(245, 176, 189);
ellipse(100, 260, 90, 100);
ellipse(400, 260, 90, 100);
fill(255, 184, 197);
circle(250, 250, 300);
//eyes
fill(3, 161, 252);
stroke(1);
strokeWeight(5);
ellipse(210, 200, 30, 70);
ellipse(290, 200, 30, 70);
noStroke();
fill(0);
ellipse(210, 190, 30, 50);
ellipse(290, 190, 30, 50);
fill(255);
ellipse(210, 185, 23, 35);
ellipse(290, 185, 23, 35);
//mouth
fill(190, 0, 0);
arc(250, 230, 40, 65, 0, PI, CHORD);
fill(255, 0, 0);
ellipse(250, 253, 25, 20);
//blush
fill(250, 132, 165);
ellipse(190, 255, 50, 25);
ellipse(310, 255, 50, 25);
}