xxxxxxxxxx
223
let h = [];
let b = [];
// let names = [ "Sans", "&", "Papyrus"];
let song;
function preload() {
song = loadSound("Undertale - Papyrus.m4a");
}
function setup() {
createCanvas(400, 400);
// song.loop();
angleMode(DEGREES);
rectMode(CENTER);
for (let y = 20; y < height; y = y + 60) {
for (let x = 20; x < width; x = x + 60) {
h.push(new heart(
x,
y,
20
));
}
}
b.push(new bro1(
width/3 *2,
height/3 *2,
26
));
b.push(new bro2(
width/3,
height/3,
-24
));
}
function draw() {
background(0);
frameRate(12);
for (let i = 0; i < h.length; i = i + 1) {
h[i].update();
}
for (let i = 0; i < b.length; i = i + 1) {
b[i].update();
}
// for(let i = 0; i < names.length; i = i + 1) {
// textSize(32);
// fill(255);
// text(names[i], random(width),random(height));
// }
}
class bro1 {
constructor(x, y, s) {
this.x = x; //x
this.y = y; //y
this.s = s; //speed
this.r = 0; //rotation
}
update() {
push();
translate(this.x, this.y);
rotate(this.r);
this.r = this.r + this.s;
Sans();
pop();
function Sans() {
//skull
fill(255);
// fill(random(0,255), random(0,255), random(0,255));
noStroke();
ellipse(0, -22, 70, 55);
ellipse(0, 0, 67, 40);
//eye sockets
fill(0);
ellipse(-15, -20, 20, 15);
ellipse(15, -20, 20, 15);
//nose?
rect(0, -6, 9, 5);
rect(0, -11, 5, 5);
//eye lines
stroke(0);
strokeWeight(2);
line(-7, -17, -15, -9);
line(-15, -9, -20, -9);
line(7, -17, 15, -9);
line(15, -9, 20, -9);
//pupils?
stroke(255);
strokeWeight(5);
point(-14, -18);
point(14, -18);
//smile
fill(0);
noStroke();
beginShape();
curveVertex(-22, 0);
curveVertex(-22, 0);
curveVertex(-5, 3);
curveVertex(3, 3);
curveVertex(21, 0);
curveVertex(21, 0);
endShape();
beginShape();
curveVertex(-28, 0);
curveVertex(-28, 0);
curveVertex(-12, 16);
curveVertex(10, 16);
curveVertex(27, 0);
curveVertex(27, 0);
endShape();
stroke(0);
strokeWeight(2);
fill(255);
rect(-13, 6, 6, 11);
rect(-5, 7, 9, 13);
rect(3, 7, 9, 13);
rect(11, 6, 6, 11);
}
}
}
class bro2 {
constructor(x, y, s) {
this.x = x; //x
this.y = y; //y
this.s = s; //speed
this.r = 0; //rotation
}
update() {
push();
translate(this.x, this.y);
rotate(this.r);
this.r = this.r + this.s;
Papyrus();
pop();
function Papyrus() {
//skull
fill(0);
rect(5, -15, 34, 80);
noStroke();
fill(255);
// fill(random(0,255), random(0,255), random(0,255));
ellipse(1, -35, 60, 60);
ellipse(-1, -15, 42, 35);
rect(24, -2, 4, 50);
beginShape();
vertex(22, 15);
vertex(26, 25);
vertex(26, 24);
vertex(17, 35);
vertex(-18, 35);
vertex(-18, 25);
vertex(17, 24);
endShape(CLOSE);
//eye sockets
fill(0);
beginShape();
vertex(-15, -25);
vertex(-7, -25);
vertex(-7, -40);
vertex(-15, -50);
endShape(CLOSE);
rect(15, -32, 7, 15);
//nose?
rect(-3, -11, 4, 10);
rect(0, -15, 4, 10);
rect(3, -9.5, 4, 7);
//eye lines
stroke(0);
strokeWeight(2);
line(-20, -49, -15, -49);
line(-7, -39, -4, -35);
line(-16, -25, -9, -25);
line(8, -40, 23, -40);
line(10, -25, 20, -25);
//smile
fill(255);
rect(-12, 2, 6, 9);
rect(-5, 3, 8, 11);
rect(3, 3, 8, 11);
rect(10, 2, 6, 9);
rect(-11, 21, 5, 5);
rect(-6, 23, 5, 9);
rect(0, 23, 5, 9);
rect(6, 23, 5, 9);
rect(11, 21, 5, 5);
}
}
}
class heart {
constructor(x, y, s) {
this.x = x; //x
this.y = y; //y
this.s = s; //speed
this.r = 0; //rotation
}
update() {
push();
translate(this.x, this.y);
rotate(this.r);
this.r = this.r + this.s;
pixelHeart();
pop();
function pixelHeart() {
noStroke();
fill(255, 0, 0);
rect(-10, 0, 7, 20);
rect(-4, 3, 7, 30);
rect(2, 9, 7, 25);
rect(8, 3, 7, 30);
rect(14, 0, 7, 20);
}
}
}