xxxxxxxxxx
130
/*
Final project combines Generative Landscape Project with the Sound Sampler.
User can click on each part of the landscape to play a different sound.
4.22.2024
*/
//global scope
var currentSlide = 1; //first slide
var totalSlides = 4;
var nextSlideActive = false;
var prevSlideActive = false;
// slide 2
var description =
"Merges the Generative Landscape from Week 9’s Functions project with the Keyboard and Sound Sampler project developed in Week 11";
//slide 3
var interaction =
"The user can click on different parts of the landscape to play different city sounds.";
//slide 4
var graphicsExample;
function preload() {
graphicsExample = loadImage("Glandscape_210.jpg");
}
function setup() {
createCanvas(650, 600);
}
function mousePressed() {
save("Glandscape_210.jpg");
}
function draw() {
background("black");
// first slide
if (currentSlide == 1) {
textSize(41);
textFont("Copperplate");
fill("pink");
textAlign(CENTER);
stroke("lightgreen");
text("Soundscape Symphony:", 65, 155, 500);
//width / 2, height / 2.8); //width / 2, height / 2.8);
textSize(30);
textFont("Papyrus");
fill("white");
text("Harmonizing Generative", 75, 275, 500);
text("Landscape with City Sounds", 75, 318, 500);
textSize(30);
text("by Jour", width / 2.0, height / 1.4);
}
//second slide
//generative landscape scroll with mouse different city sounds play
if (currentSlide == 2) {
textSize(40);
textFont("Helvetica");
fill("pink");
textAlign(CENTER);
text(description, 85, 125, 500);
}
// third slide
if (currentSlide == 3) {
textSize(40);
textFont("Helvetica");
fill("pink");
textAlign(CENTER);
text(interaction, 85, 150, 500);
}
// slide four graphics example
if (currentSlide == 4) {
image(graphicsExample, 0, 0);
textAlign(CENTER);
textSize(60);
textFont("Copperplate");
stroke("white");
fill("orange");
text("Graphics", width / 1.8, height / 2.3); /// 2, height / 2);
}
nextSlideActive = button(380, 510, 60, 20, "Next"); //button logic
prevSlideActive = button(215, 510, 60, 20, "Back"); //button logic
}
function mousePressed() {
if (nextSlideActive && currentSlide < totalSlides) {
currentSlide += 1;
}
if (prevSlideActive && currentSlide > 1) {
currentSlide -= 1;
}
}
// draws a button, returns whether it is acitve
//button logic
function button(x, y, w, h, txt) {
var isActive = false;
if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {
isActive = true;
fill("yellow");
} else {
fill("orange");
}
//fill("orange");
rect(x, y, w, h);
textSize(h);
fill(0);
textAlign(LEFT, TOP);
textFont("Impact");
text(txt, x + 11, y + 2);
// return button state to main program
return isActive;
}