xxxxxxxxxx
117
/*
final project pitch template
4.15.2024
*/
var currentSlide = 1;
var totalSlides = 5;
var nextSlideActive = false;
var prevSlideActive = false;
// slide 2
var description = "My final projet combines the Keyboard input project & the Animation project";
// slide 3
var interaction = "The user will be able to use the Mouse to move the spaceship around, they will also be able to press a key to emit a laser beam from the space ship";
var graphicsExample;
function preload() {
graphicsExample = loadImage('ufo.png');
}
var graphicsExample2;
function preload() {
graphicsExample2 = loadImage('ufo2.png');
}
function setup() {
createCanvas(400, 400);
textFont("helvetica");
}
function draw() {
background(20);
// first slide
if (currentSlide == 1) {
textAlign(LEFT, LEFT);
textSize(100);
fill("#19BC20");
text('My Final Project', 2 / 2, 100 / 2);
text('by Dante', 2 / 2, 200 / 2 + 50);
}
if (currentSlide == 2) {
textSize(20);
textAlign(LEFT);
text(description, 50, 50, 300);
}
if (currentSlide == 3) {
textSize(20);
textAlign(LEFT);
text(interaction, 50, 50, 300);
}
// graphics example
if (currentSlide == 4) {
image(graphicsExample, 0, 0);
textAlign(CENTER);
textSize(40);
text("UfO example", width / 2, height / 2);
}
// graphics example
if (currentSlide == 5) {
image(graphicsExample2, 0, 0);
textAlign(CENTER);
textSize(40);
text("UfO example2", width / 2, height / 2);
}
nextSlideActive = button(300, 350, 60, 20, "Next");
prevSlideActive = button(220, 350, 60, 20, "Prev");
}
function mousePressed() {
if (nextSlideActive && currentSlide < totalSlides) {
currentSlide += 1;
}
if (prevSlideActive && currentSlide > 1) {
currentSlide -= 1;
}
}
// draws a button, returns whether it is active
function button(x, y, w, h, txt) {
var isActive = false;
if (mouseX > x && mouseX < x + w &&
mouseY > y && mouseY < y + h) {
isActive = true;
fill('#4CAF50w');
} else {
fill("black");
}
rect(x, y, w, h);
textSize(h);
fill("#19BC20");
textAlign(LEFT, TOP);
text(txt, x + 2, y + 2);
// return button state to main program
return isActive;
}