xxxxxxxxxx
132
/* Final project by Victoria Belandria */
var currentSlide = 1;
var totalSlides = 4;
var nextSlideActive = false;
var prevSlideActive = false;
/*-----------------slide 3------*/
var description = "By pressing the target, it will change position to a random area of the scree, allowing the user to keep playing"
var description1 = "Each click will have a sound of a laser, and once you press in the correct target, it will play a different sound"
/* ----------SLIDE 4-----------*/
var description2 = "This is an ilustration/animation from one of our classes that I will use as the foundation for my project idea."
/* ------------------------------*/
var example;
function preload(){
example = loadImage('example.png');
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background("#C6D5F8");
// FIRST SLIDE
if (currentSlide == 1){
background("#C6D5F8");
textAlign(CENTER);
textSize(40);
fill("#3F1C7C");
text("Spaceship", width/2, height/3);
textSize(20);
text("by Victoria Belandria", width/2, height/3 + 50);
}
// SECOND SLIDE
if (currentSlide == 2){
background("#C6D5F8");
textAlign(CENTER);
textSize(20);
fill("#3F1C7C");
text("My Project will use randomness along with custom functions and sound to create an interactive game where the user can click on different targets to eliminate the enemy", 50, 100, 300, 300);
}
// THIRD SLIDE
if (currentSlide == 3){
background("#C6D5F8");
textAlign(CENTER);
textSize(20);
fill("#3F1C7C");
text( description, 50, 100, 300, 300);
textSize(20);
text(description1, 50, 210, 300, 300);
}
//FOURTH SLIDE
if (currentSlide == 4){
background("#C6D5F8");
textAlign(CENTER);
textSize(20);
fill("#3F1C7C");
text(description2, 50, 50, 300, 300 );
image( example, 50, 160 , 300, 180);
}
//------------- BUTTON--------------//
nextSlideActive = button(300, 350, 60, 30, "Next")
prevSlideActive = button(50, 350, 60, 30, "Prev")
}
//DRAWS A BUTTON AND RETURNS WHETHER IT IS ACTIVE
function button(x, y, w, h, txt){
//button activation
var isActive = false;
if(mouseX> x && mouseX < x + w &&
mouseY > y && mouseY < y + h) {
isActive = true;
fill('#CBC0DE');
} else{
fill("#3F1C7C");
}
//button style
rect(x, y, w, h);
textSize(20);
fill(255);
textAlign(LEFT, TOP);
text(txt,x + 10,y + 7);
return isActive;
}
function mousePressed (){
if (nextSlideActive && currentSlide < totalSlides){
currentSlide += 1;
}
if (prevSlideActive && currentSlide > 1){
currentSlide -= 1;
}
}