xxxxxxxxxx
332
var doorOpen = 0;
var ready = -1;
var once = false;
let myFont;
let myFont2;
let bg;
var endMsg = "";
var c;
function preload() {
song1 = loadSound('gazondergeluid.mp3');
song2 = loadSound ('babywakker.mp3');
song3 = loadSound ('geluktspel.mp3');
soundmachine = loadSound("soundmachine2.mp3");
soundrobot = loadSound("robotsound.mp3");
soundbuisjes = loadSound("soundbuisjes2.mp3");
soundbaby = loadSound("baby.mp3");
soundwall = loadSound ("wall.mp3");
soundlaughing = loadSound ("laughingbaby.mp3");
machine = loadImage ('machine.png');
buisjes = loadImage ('buisjes.png');
robot = loadImage ('robot2.png');
start = loadImage ('start.png');
langelijnvertic = loadImage ('langelijnvertic.png');
lijnverticlinks = loadImage ('lijnverticlinks.png');
lijnverticrechts = loadImage ('lijnverticrechts.png');
lijnhorizbeneden = loadImage ('lijnhorizbeneden.png');
lijnhorizboven = loadImage ('lijnhorizboven.png');
kortstelijn = loadImage ('kortstelijn.png');
kortstelijnvertic = loadImage ('kortstelijnvertic.png');
myFont = loadFont('AlteHaasGroteskRegular.ttf');
myFont2 = loadFont('AlteHaasGroteskBold.ttf');
bg = loadImage('ground.png');
gif_createImg1 = createImg("couveusebetercrop.gif");
}
function setup() {
createCanvas(windowWidth, windowHeight);
//background (253, 196, 56);
background (bg);
c = 'white'
song1.play();
button = createImg('knopterug.png');
button.size(windowHeight/5, windowHeight/10);
button.position(windowHeight/14,windowHeight/20);
button.mousePressed(changeBH);
}
function draw() {
if(mouseX > windowHeight/20 && mouseX < windowHeight/20+windowWidth/5 && mouseY > windowHeight-windowHeight/20 && mouseY < windowHeight) {
background(bg)
once = false;
soundmachine.stop();
soundbuisjes.stop();
soundrobot.stop();
soundbaby.stop();
soundwall.stop();
soundlaughing.stop();
song2.stop();
song3.stop();
}
noStroke();
// Entrance Box
image(start,windowHeight/20+windowWidth/10-windowWidth/30,windowHeight-windowHeight/20,windowWidth/15,windowWidth/60);
//baby
gif_createImg1.position(windowWidth-windowWidth/5-windowHeight/7.1, windowHeight/10);
gif_createImg1.size(windowWidth/4.57,windowWidth/5)
// Exit Box
//fill('transparent');
//rect(windowWidth-windowWidth/5-windowHeight/8,windowHeight/10, windowWidth/5,windowWidth/5);
// Obstacles and Walls
fill(0);
// Machines
image(machine,windowWidth/12,windowHeight/5,windowWidth/11,windowWidth/11);
image(buisjes,windowWidth/3,windowHeight/4,windowWidth/20,windowWidth/9);
image(robot,windowWidth/6,windowHeight -windowHeight/2.25,windowWidth/8,windowWidth/5);
image(machine,windowWidth/2.1,windowHeight/1.4,windowWidth/11,windowWidth/11);
image(buisjes,windowWidth/1.3,windowHeight/1.8,windowWidth/20,windowWidth/9);
image(robot,windowWidth/1.7,windowHeight/4,windowWidth/12,windowWidth/7);
//Walls
fill ('white')
rect(0,0,windowHeight/20,windowHeight);
//rect(windowWidth/5+windowHeight/20,0,windowWidth-windowWidth/5-windowHeight/20,windowHeight/20);
//rect onderaan
rect(windowWidth/5+windowHeight/20,windowHeight-windowHeight/20,windowWidth,windowHeight/20);
//rect(0,windowHeight-windowHeight/20,windowWidth,windowHeight/20);
//rect bovenaan
rect(0,0,windowWidth,windowHeight/20);
rect(windowWidth-windowHeight/20,0,windowHeight/20,windowHeight);
rect(windowWidth/2,0,windowHeight/20,windowHeight/2);
//rect midden
//rect(windowWidth/2,windowHeight/2,windowHeight/20,windowHeight/2);
//lijnhorizboven
//image(lijnhorizboven, windowWidth/5+windowHeight/20,0,windowWidth-windowWidth/5-windowHeight/20-windowHeight/30,windowHeight/20)
image(lijnhorizbeneden, windowWidth/5+windowHeight/50,windowHeight-windowHeight/20,windowWidth-windowHeight/20-windowWidth/5.5,windowHeight/20)
//horizbovenkort
image(kortstelijnvertic, windowHeight/20+windowWidth/5,windowHeight -windowHeight/20,windowHeight/70,windowHeight/20);
//lijnhorizbeneden
//image(lijnhorizbeneden,0,windowHeight-windowHeight/20,windowWidth,windowHeight/20)
image(lijnhorizboven,windowHeight/20,0,windowWidth-windowHeight/20,windowHeight/20)
//verticlijnlinks
image(lijnverticlinks,0,windowHeight/30,windowHeight/20,windowHeight);
//verticlijnrechts
image(lijnverticrechts,windowWidth-windowHeight/20,0,windowHeight/20,windowHeight);
//middenrechts
image(lijnverticlinks, windowWidth/1.99,0+windowHeight/30,windowHeight/20,windowHeight/2-windowHeight/60);
//middenlinks
image(lijnverticrechts, windowWidth/2.01,0+windowHeight/30,windowHeight/20,windowHeight/2-windowHeight/60);
//middenkort
image(kortstelijn, windowWidth/2,windowHeight/2.01,windowHeight/20,windowHeight/70);
// Play
if(mouseX > windowHeight/20 && mouseX < windowHeight/20+windowWidth/5 && mouseY > windowHeight-windowHeight/20 && mouseY < windowHeight-windowHeight/20+windowHeight/20) {
ready = 1;
endMsg = "";
}
if(ready == 1) {
strokeWeight(2);
stroke('white');
line(mouseX, mouseY, pmouseX, pmouseY);
}
// Win Scenario
if(ready == 1 && mouseX > windowWidth-windowWidth/5-windowHeight/10 && mouseX < windowWidth-windowWidth/5-windowHeight/10+windowWidth/5 && mouseY > windowHeight/10 && mouseY < windowHeight/10+windowWidth/5) {
// Speed Cheat Check
if(dist(pmouseX,pmouseY, mouseX,mouseY) > 20) {
ready = 0;
//endMsg = "Slow Down!";
//c = 'red';
} else {
endMsg = "Goed zo! Gelukt!";
noStroke();
if (!once){
soundlaughing.play();
song3.play();
once = true;
}
//c = 'white'
//text(s, windowWidth/2, windowHeight/2, windowWidth/1.2, windowHeight);
}
}
// Opening message
//
if(ready == -1) {
c = 'white';
endMsg = "Ga naar de baby zonder geluid\n te maken! Begin bij start.";
}
textSize(windowWidth/30);
fill(c);
textFont(myFont);
textAlign(CENTER);
text(endMsg, windowWidth/2, windowHeight/2+windowHeight/10);
// Lose Scenarios
//machine1
if(mouseX > windowWidth/12 && mouseX < windowWidth/12+windowWidth/11 && mouseY > windowHeight/5 && mouseY < windowHeight/5+windowWidth/11) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundmachine.play();
soundbaby.play();
song2.play();
once = true;
}
}
//machine2
if(mouseX > windowWidth/2.1 && mouseX < windowWidth/2.1+windowWidth/11 && mouseY > windowHeight/1.4 && mouseY < windowHeight/1.4+windowWidth/11) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundmachine.play();
soundbaby.play();
song2.play();
once = true;
}
}
//buisjes1
if(mouseX > windowWidth/3 && mouseX < windowWidth/3+windowWidth/20 && mouseY > windowHeight/4 && mouseY < windowHeight/4+windowWidth/9) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundbuisjes.play();
soundbaby.play();
song2.play();
once = true;
}
}
//buisjes2
if(mouseX > windowWidth/1.3 && mouseX < windowWidth/1.3+windowWidth/20 && mouseY > windowHeight/1.8 && mouseY < windowHeight/1.8+windowWidth/9) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundbuisjes.play();
soundbaby.play();
song2.play();
once = true;
}
}
//robot1
if(mouseX > windowWidth/6 && mouseX < windowWidth/6+windowWidth/8 && mouseY > windowHeight -windowHeight/2.25 && mouseY < windowHeight -windowHeight/2.25+windowWidth/5) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundrobot.play();
soundbaby.play();
song2.play();
once = true;
}
}
//robot2
if(mouseX > windowWidth/1.7 && mouseX < windowWidth/1.7+windowWidth/12 && mouseY > windowHeight/4 && mouseY < windowHeight/4+windowWidth/7) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundrobot.play();
soundbaby.play();
song2.play();
once = true;
}
}
//Walls
if(mouseX > 0 && mouseX <windowHeight/20 && mouseY > 0 && mouseY <windowHeight) {
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundwall.play();
soundbaby.play();
song2.play();
once = true;
}
}
//Deze aanpassen
if(mouseX > 0 && mouseX < windowWidth && mouseY > 0 && mouseY < windowHeight/20) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundwall.play();
soundbaby.play();
song2.play();
once = true;
}
}
//Deze aanpassen
if(mouseX > windowWidth/5+windowHeight/20 && mouseX < windowWidth/5+windowHeight/20+windowWidth && mouseY > windowHeight-windowHeight/20 && mouseY < windowHeight-windowHeight/20+windowHeight/20) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundwall.play();
soundbaby.play();
song2.play();
once = true;
}
}
if(mouseX > windowWidth-windowHeight/20 && mouseX <windowWidth-windowHeight/20+windowHeight/20 && mouseY >0 && mouseY <windowHeight) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundwall.play();
soundbaby.play();
song2.play();
once = true;
}
}
if(mouseX > windowWidth/2 && mouseX < windowWidth/2+windowHeight/20 && mouseY > 0 && mouseY <windowHeight/2) {
ready = 0;
endMsg = "De baby is wakker!\nGa naar Start.";
c = 'white'
if (!once){
soundwall.play();
soundbaby.play();
song2.play();
once = true;
}
}
if(mouseX == 0 && mouseY == 0)
ready = -1;
}
function changeBH() {
window.open("https://editor.p5js.org/Rose_Thys/present/aRgj3LAYC");
window.open("https://editor.p5js.org/Rose_Thys/present/YR7hm7PGT", "_self").close();
}