var soundBritney, soundCeline, soundDestiny;
var btnBritney, btnCeline, btnDestiny;
var descriptionTxt = "Listen to three of the biggest hits of the 90's. These women have made history with music touching both people's ears and hearts.";
var headerTxt = "90s Hits";
var currentlyPlayingTxt = "...";
constructor(imgPath, width, height, x, y) {
this.img = loadImage(imgPath);
image(this.img, this.x, this.y, this.width, this.height);
return mouseX > this.x && mouseX < this.x + this.width &&
mouseY > this.y && mouseY < this.y + this.height;
playSound(sound, others) {
others.forEach(function(other) {
if (!sound.isPlaying()) {
soundBritney = loadSound('Britney.mp3');
soundCeline = loadSound('Celine.mp3');
soundDestiny = loadSound('Destiny.mp3');
btnBritney = new ImageButton("Britney.png", 120, 120, 50, height - 460);
btnCeline = new ImageButton("Celine.png", 120, 120, 250, height - 460);
btnDestiny = new ImageButton("Destiny.png", 120, 120, 450, height - 460);
text(headerTxt, width / 2, 100);
text(descriptionTxt, 50, 200, width - 100);
if (soundBritney.isPlaying()) {
currentlyPlayingTxt = 'Now playing: Britney Spears';
} else if (soundCeline.isPlaying()) {
currentlyPlayingTxt = 'Now playing: Celine Dion';
} else if (soundDestiny.isPlaying()) {
currentlyPlayingTxt = 'Now playing: Destiny\'s Child';
currentlyPlayingTxt = '...';
text(currentlyPlayingTxt, 50, height - 150, width - 100);
function mousePressed() {
if (btnBritney.isMouseOver()) {
btnBritney.playSound(soundBritney, [soundCeline, soundDestiny]);
} else if (btnCeline.isMouseOver()) {
btnCeline.playSound(soundCeline, [soundBritney, soundDestiny]);
} else if (btnDestiny.isMouseOver()) {
btnDestiny.playSound(soundDestiny, [soundBritney, soundCeline]);
function mouseReleased() {
if (btnBritney.isMouseOver()) {
} else if (btnCeline.isMouseOver()) {
} else if (btnDestiny.isMouseOver()) {