xxxxxxxxxx
152
//to display stories in typewriter format
//global variable to display and animate text
var message = "";
// where the cursor starts typing from
var index = 0;
//time since code started running
var lastMillis = 0;
// to display the full screen image
var picture;
// do not want to display the fullscreen image
var display = false;
//have created an array of song objects with different properties
let songs = [
{
//fill in details / story text that I want / and is my first object
name: "Dave",
desc:
"* Take five by Dave Brubeck * I was 17 and I had just moved away from home and missing family and crying alone in college. My father is a musician and used to play ‘take 5’ at concerts when I was little and my sister and I would sing along in the audience softly while my mum smiled sweetly. It became the song we bonded over. I realized in that moment, even if I can’t always be around people I love I can listen to music that makes me feel closer to them. I took my phone out and played ‘take 5. ’And suddenly I felt so calm. Now when I feel low I just listen to music and feel close to my special people. It helps me take 5 to calm down and hold gratitude close when life feels like too much. Hehe.*Rohini,25*",
},
// second object
{
name: "TS",
desc:
"* All too well by Taylor Swift * Any Swiftie knows that this is one of the best songs Taylor's ever written, it's been my no.1 for seven years now. All Too Well has always been a weirdly cathartic song to sing out loud for me because of how sad it is. It's interestingly been there for me at extremely random points of my life, creating the most unexpected memories. It was my favourite song when a friend and I were in line for an entrance exam but filling out time by trying to mimick the taylor swift hair flip from when she performed this song at the Grammys. But it was also there for me through every ex boyfriend, every infatuation or every time a romantic situation went sour. But maybe most important of all, it's been THE song to scream with your friends when you're drunk at 3AM at a party.And maybe that last bit is what I miss most of all, the euphoria of belting out a taylor song at that moment in the night when half the crowd is asleep and the other half should've left a long time ago. I can't wait till I can do that again because who doesn't want to scream out 'you called me up again just to break me like a promise, SO CASUALLY CRUEL IN THE NAME OF BEING HONEST, I'M A CRUMPLED UP PIECE OF PAPER LYING HERE *Veer,24*",
},
{
// Third object
name: "Be",
desc:
" * Irreplaceable by Beyoncé * In 2007, we had a cd with all songs that won a Grammy the previous year. My mum would come back home everyday after work, put on her high heals and dance to that cd. It had been a really rough year for us as a family and so this song and that moment for me is what resilience looks like. *Leah,25*",
},
//Fourth object
{
name: "Kodaline",
desc:
"* All I want by Kodaline * I remember hearing this song for the very first time when this guy I was seeing sent it to me, he then told me how this was how he felt when he was with his estranged wife, that all he needed, in that moment,washer. I remember feeling the deepest sorrow and the highest joy there is. That was the moment I fell in love with the man that was still falling out of love with his wife.*Prachi,Unknown* ",
},
// Fifth object// Didn't work
{
name:"Boots",
desc:"Following the Syrian Christian tradition, I was named after my grandmother- Dipika. I like to think that I inherited more from her than just her name. Her love for sports, making friends wherever she went, listening to their problems, offering unsolicited advice, not to mention her love of hotchocolate fudge. What I did not inherit was her confidence. I still find it hard to talk in front of a crowd, but she was a born performer. She could break into song while sitting at a restaurant, stand in front of a crowd, recite and dance without a care in the world. She always enjoyed a good beat. The lyrics didn't matter even if they were questionable. She would start cha- chaing no matter where she was and get others to join her. Today will be a year since she passed and this was probably her favourite song. It embodies her no-nonsense personality and the ability to get up and move on when life knocks you down. She always reminded us that as women, our boots were made for walking, no matter what anyone said. I know that no matter where I am in life, this song will always be the soundtrack to my memory of her. "
}
];
function preload() {
//created a for loop to load the images and sounds by adding them as properties to my songs array
for (var i = 0; i < 4; i++) {
songs[i].loadedImage = loadImage(songs[i].name + ".jpg");
songs[i].loadedSound = loadSound(songs[i].name + ".mp3");
}
//sets picture to a default vaule
picture = songs[0].loadedImage;
}
function mouseClicked() {
//position of cursor
let currentX = mouseX / 100;
//checks if a song is playing
let songIsPlaying = false
for (var i = 0; i < 4; i++){
if (songs[i].loadedSound.isPlaying()) {
songIsPlaying = true;
}
}
//to pause the song
if (songIsPlaying) {
for (var i = 0; i < 4; i++){
songs[i].loadedSound.stop();
}
//to remove full screen
display = false;
message = "";
} else {
lastMillis = millis();
index = 0;
display = true;
// plays the song based on the postion of the mouse
if (currentX < 1) {
picture = songs[0].loadedImage;
songs[0].loadedSound.play();
message = songs[0].desc;
} else if (currentX > 1 && currentX < 2) {
picture = songs[1].loadedImage;
songs[1].loadedSound.play();
message = songs[1].desc;
} else if (currentX > 2 && currentX < 3) {
picture = songs[2].loadedImage;
songs[2].loadedSound.play();
message = songs[2].desc;
} else if (currentX > 3 && currentX < 4) {
picture = songs[3].loadedImage;
songs[3].loadedSound.play();
message = songs[3].desc;
}
// // to add another song
// else if (currentX > 4 && currentX < 5) {
// picture = songs[4].loadedImage;
// songs[4].loadedSound.play();
// message = songs[4].desc;
// }
}
}
function setup() {
createCanvas(400, 600);
background(0, 0, 0);
textAlign(LEFT, TOP);
textSize(15);
}
function draw() {
//repaint to white to display text
if(!display) {
background (0)
}
//drawing every album cover
image(songs[0].loadedImage, 0, 0, 100, 100);
image(songs[1].loadedImage, 100, 0, 100, 100);
image(songs[2].loadedImage, 200, 0, 100, 100);
image(songs[3].loadedImage, 300, 0, 100, 100);
//could I make this into a nested for loop?
// this is to make the album cover art a big screen
if(display) {
background (255);
}
text(message.substring(0, index), 0, 0, 400, 400);
if (millis() > lastMillis + 50) {
index = index + 1;
//ONE WORD AT A TIME
// while(message.charAt(index) != ' ' &&
// index < message.length){
// index = index + 1;
// }
lastMillis = millis();
}
}