xxxxxxxxxx
256
// Short Story Called "Maybe Someday but Not a Monday" by Me and Art by my Girlfriend
// Made in 2023 5/23
//*Use the left and right arrow keys to cycle through the pictures. And use the spacebar to start narration.*
//There is a lot of code here and i did my best to optimize it so i hope it doesnt lag you.
/*these are the variables for the pages i will make
p=page*/
var cover;
var p1;
var p2;
var p3;
var p4;
var pfifth; //i was afraid using p5 would give me issues
var p6;
var p7;
var p8;
var p9;
var p10;
/*these are the variables for the sounds i will use
long but necessary*/
var s1;
var s2;
var s3;
var s4;
var s5;
var s6;
var s7;
var s8;
var s9;
var s10;
var space = 32;
//the function to prepare the photos and sounds to be used
function preload() {
//just be glad you didnt have to type all this out ;-;
cover = loadImage("image/cover.JPG");
p1 = loadImage("image/p1.png");
p2 = loadImage("image/p2.png");
p3 = loadImage("image/p3.png");
p4 = loadImage("image/p4.png");
pfifth = loadImage("image/p5.png");
p6 = loadImage("image/p6.png");
p7 = loadImage("image/p7.png");
p8 = loadImage("image/p8.png");
p9 = loadImage("image/p9.png");
p10 = loadImage("image/p10.png");
s1 = loadSound("sound/ap1.wav");
s2 = loadSound("sound/ap2.wav");
s3 = loadSound("sound/ap3.wav");
s4 = loadSound("sound/ap4.wav");
s5 = loadSound("sound/ap5.wav");
s6 = loadSound("sound/ap6.wav");
s7 = loadSound("sound/ap7.wav");
s8 = loadSound("sound/ap8.wav");
s9 = loadSound("sound/ap9.wav");
s10 = loadSound("sound/ap10.wav");
// just kidding i copied and pasted the text
}
function setup() {
createCanvas(600, 521);
// This piece of code will get rid of spikey text borders. Ew ;-;
canvas, (drawingContext.miterLimit = 1);
}
/* you already know the dealio
isl is the image size lenght wise
ish is image size hieght wise
and cen keeps it centered*/
var isl = 550;
var ish = 400;
var cen = (600 - isl) / 2;
var title1 = "Maybe Someday";
var title2 = "But NOT a Monday";
var instr =
"(Use the left and right arrow keys to navigate and spacebar for audio)";
/* I decided that a variable was needed to switch between images like a comic book*/
var pagenum = 0;
function draw() {
background("#7d77c9");
if (pagenum === 0) {
image(cover, cen, cen, isl, ish);
stroke("#C3C977");
strokeWeight("5");
textSize(15);
text(instr, cen + 30, cen + 480);
textSize(70);
textFont("cursive");
text(title1, cen + 10, cen + 40);
textSize(60);
text(title2, cen + 10, cen + 380, 650, 600);
}
if (pagenum === 1) {
image(p1, cen, cen, isl, ish);
}
if (pagenum === 2) {
image(p2, cen, cen, isl, ish);
}
if (pagenum === 3) {
image(p3, cen, cen, isl, ish);
}
if (pagenum === 4) {
image(p4, cen, cen, isl, ish);
}
if (pagenum === 5) {
image(pfifth, cen, cen, isl, ish);
}
if (pagenum === 6) {
image(p6, cen, cen, isl, ish);
}
if (pagenum === 7) {
image(p7, cen, cen, isl, ish);
}
if (pagenum === 8) {
image(p8, cen, cen, isl, ish);
}
if (pagenum === 9) {
image(p9, cen, cen, isl, ish);
}
if (pagenum === 10) {
image(p10, cen, cen, isl, ish);
}
}
//Gives the user the ability to interact through the keyboard
function keyPressed() {
//keycode makes the arrow imputs on keyboard do something
if (keyCode === RIGHT_ARROW) {
pagenum++;
}
if (keyCode === LEFT_ARROW) {
pagenum = pagenum - 1;
}
//this code loops you to the begining and makes it so you can't go lower than the cover page. sure is handy!!
if (pagenum > 10) {
pagenum = 0;
}
if (pagenum < 0) {
pagenum = 0;
}
/*This part of the code is interesting. I intended to make it so that once you hit space you can have the page narrated at your own pace. But it seems the code makes it so that it auto reads every page once you hit space once. Happy little accident i guess.
***This was fixed with the help of my professor. Turns out i had "s.play" in the wrong spot
*/
if (pagenum === 1) {
if (keyCode === space) {
s1.playMode("untilDone");
s1.play();
}
} else {
s1.stop();
}
if (pagenum === 2) {
if (keyCode === space) {
s2.playMode("untilDone");
s2.play();
}
} else {
s2.stop();
}
if (pagenum === 3) {
if (keyCode === space) {
s3.playMode("untilDone");
s3.play();
}
} else {
s3.stop();
}
if (pagenum === 4) {
if (keyCode === space) {
s4.playMode("untilDone");
s4.play();
}
} else {
s4.stop();
}
if (pagenum === 5) {
if (keyCode === space) {
s5.playMode("untilDone");
s5.play();
}
} else {
s5.stop();
}
if (pagenum === 6) {
if (keyCode === space) {
s6.playMode("untilDone");
s6.play();
}
} else {
s6.stop();
}
if (pagenum === 7) {
if (keyCode === space) {
s7.playMode("untilDone");
s7.play();
}
} else {
s7.stop();
}
if (pagenum === 8) {
if (keyCode === space) {
s8.playMode("untilDone");
s8.play();
}
} else {
s8.stop();
}
if (pagenum === 9) {
if (keyCode === space) {
s9.playMode("untilDone");
s9.play();
}
} else {
s9.stop();
}
if (pagenum === 10) {
if (keyCode === space) {
s10.playMode("untilDone");
s10.play();
}
} else {
s10.stop();
}
}