You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

89 lines
2.6 KiB

let imgL;
let imgR;
let imagesL = [];
let imagesR = [];
let hearts = [];
function preload() {
imgL = loadImage('bedrandomL.png');
imgR = loadImage('bedrandomR.png');
//imgLy = loadImage('l_yellow.png');
//imgRb = loadImage('r_blue.png');
imagesL[0] = loadImage('l_blue.png');
imagesL[1] = loadImage('l_green.png');
imagesL[2] = loadImage('l_rose.png');
imagesL[3] = loadImage('l_yellow.png');
imagesR[0] = loadImage('r_blue.png');
imagesR[1] = loadImage('r_green.png');
imagesR[2] = loadImage('r_rose.png');
imagesR[3] = loadImage('r_yellow.png');
}
function setup() {
createCanvas(window.innerWidth, window.innerHeight);
colorMode(HSB);
background(315, 20, 70);
angleMode(DEGREES);
imageMode(CENTER);
for(let i = 0; i < 75; i++){
hearts.push(new Heart(random(0, window.innerWidth), random(0, window.innerHeight), random(5,25), color(random(285,320),random(30,75),random(65,100))));
hearts[i].show();
}
image(imgL, window.innerWidth/4, window.innerHeight/2);
image(imgR, 3*window.innerWidth/4, window.innerHeight/2);
knopf = createButton('Wo soll Selina schlafen?');
knopf.size(250, 75)
var col = color(275, 51, 75)
knopf.style('background-color', col)
knopf.style('font-size', '15pt')
knopf.position(window.innerWidth/2 - knopf.width/2, window.innerHeight/2 - knopf.height/2);
knopf.mousePressed(entscheidung);
}
let a
function entscheidung() {
//a = Math.random() < 0.5 ? true : false
if(Math.random() < 0.5) {
a = true
} else {
a = false
}
if(a) {
image(random(imagesL), window.innerWidth/4, window.innerHeight/2)
image(imgR, 3*window.innerWidth/4, window.innerHeight/2)
} else {
image(random(imagesR), 3*window.innerWidth/4, window.innerHeight/2)
image(imgL, window.innerWidth/4, window.innerHeight/2)
}
}
class Heart {
constructor(x, y, r, c){
this.x = x;
this.y = y;
this.r = r;
this.c = c;
}
show(){
fill (this.c);
noStroke();
ellipse(this.x-23/25*this.r, this.y-10/25*this.r, 2*this.r, 2*this.r);
ellipse(this.x+23/25*this.r, this.y-10/25*this.r, 2*this.r, 2*this.r);
beginShape();
vertex(this.x, this.y-10/25*this.r);
vertex(this.x-23/25*this.r+cos(137)*this.r, this.y-10/25*this.r+sin(137)*this.r);
vertex(this.x, this.y+50/25*this.r);
vertex(this.x+23/25*this.r+cos(38)*this.r, this.y-10/25*this.r+sin(38)*this.r);
endShape(CLOSE);
}
}