xxxxxxxxxx
78
/*
final project pitch with sound - Gal Ben Baruch
*/
var slideCount = 3;
var currentSlide = 1;
var mouseWasPressed = false;
function preload() {
soundSampler = loadImage("sound sampler.png");
}
function setup() {
createCanvas(600, 400);
}
function draw() {
background(220);
if (currentSlide == 1) {
textAlign(CENTER, CENTER);
fill("black");
textSize(50);
text("My Final project", width / 2, height / 2);
} else if (currentSlide == 2) {
textSize(20);
text(
"I am gonna expand on the sound sampler project, I will add more sounds and create some shapes to simulate a drum kit setup, with diffrent keys to trigger a diffrent sound, and light up the drum that is being played with a color, and add a button that will change the sound of the drum kit from calssic, to punk rock, to metal",
50,
30,
500
);
} else if (currentSlide == 3) {
imageMode(CENTER);
image(soundSampler, 300, 200, 600, 400);
}
button(width - 90, height - 50, "Previous", previousSlide);
button(width - 90, height - 25, "Next", nextSlide);
}
function nextSlide() {
if (currentSlide < slideCount) {
currentSlide++;
}
}
function previousSlide() {
if (currentSlide > 0) {
currentSlide--;
}
}
function button(x, y, dir, callback) {
var w = 75;
var h = 20;
if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {
if (mouseIsPressed) {
if (!mouseWasPressed) {
callback();
mouseWasPressed = true;
}
fill("red");
} else {
fill("blue");
mouseWasPressed = false;
}
} else {
fill("white");
}
strokeWeight(2);
rect(x, y, w, h, 5);
fill("black");
textSize(15);
text(dir, x + 40, y + 10);
}