xxxxxxxxxx
92
var currentSlide = 1;
var totalSlides = 4;
var nextSlideActive = false;
var prevSlideActive = false;
var projectDescription = 'My final project will be a combination of the Interactive Comic Assignment as well as the Animation Assignment. The code will create a mini game that displays various different kirbys falling down the users screen.'
var interactionDescription = 'The user will be able to hold and drag a basket across their screen and attempt to catch as many kirbys as they can within the time limit (aprox. 30 sec).'
var graphics;
function preload() {
graphics = loadImage('Graphics.jpg');
}
function setup() {
createCanvas(400, 400);
textFont('erdana');
}
function draw() {
background(220);
fill('black')
// Slide 1
if (currentSlide == 1) {
textAlign(CENTER, CENTER);
textSize(35);
text('My Final Project', width / 2, height / 2 - 20);
textSize(30);
text('By Sierra Corporan', width / 2, height / 2 + 50);
}
// Slide 2
if (currentSlide == 2) {
textAlign(LEFT, TOP);
textSize(20)
text(projectDescription, 50, 100, 300);
}
// Slide 3
if (currentSlide == 3) {
textSize(20);
text(interactionDescription, 50, 100, 300);
}
// Slide 4
if (currentSlide == 4) {
image(graphics, 0, 0);
graphics.resize(400, 400);
textAlign(CENTER, CENTER);
}
// Next Button
nextSlideActive = button(300, 360, 60, 20, 'Next');
// Prev Button
prevSlideActive = button(200, 360, 60, 20, 'Prev');
}
function mousePressed() {
if (nextSlideActive && currentSlide < totalSlides) {
currentSlide += 1;
}
if (prevSlideActive && currentSlide > 1) {
currentSlide -= 1;
}
}
function button(x, y, w, h, txt) {
var isActive = false;
if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {
isActive = true;
fill('pink')
} else {
fill ('white')
}
rect(x, y, w, h);
textSize(h);
textAlign(LEFT, TOP)
fill('black')
text(txt, x + 5, y);
// Return button state to main program
return isActive;
}