Struggling to create a dropdown menu in p5js that showcases images. Facing issues with loading images, unlike in other sketches where the problem did not occur. Seeking a fresh perspective to resolve this error. Appreciate any assistance!
let picker;
let drum1, drum2, drum3, drum4, drum5;
let img;
let drumType = 'what';
function setup() {
createCanvas(windowWidth, windowHeight);
drum1 = loadImage('drum1.jgp');
drum2 = loadImage('drum2.jpg');
drum3 = loadImage('drum3.jpg');
drum4 = loadImage('drum4.jpg');
drum5 = loadImage('drum5.jpg');
textAlign(CENTER);
background(200);
picker = createSelect();
picker.position(10, 10);
picker.option('djembe');
picker.option('two hand drums');
picker.option('one hand drum');
picker.option('Talking drum');
picker.option('five hand drums');
picker.changed(pickEvent);
img = drum5;
}
function draw() {
background(200, 220, 10);
textAlign(LEFT);
image(img, 0, 0, width, height);
text(trim + ' is a good drum', 10, 50); // look up what trim is
}
function pickEvent() {
// get the item chosen with .value()
drumType = picker.value();
if (drumType === 'djembe') {
img = drum1;
} else if (drumType === 'two hand drum') {
img = drum2;
} else if (drumType === 'one hand drum') {
img = drum3;
} else if (drumType === 'talking drum'){
img = drum4;
} else {
img = drum5;
}
}https://i.sstatic.net/pBc7dLXf.jpg https://i.sstatic.net/YkgaDzx7.jpg https://i.sstatic.net/UmXUufqE.jpg https://i.sstatic.net/E49GT3SZ.jpg https://i.sstatic.net/vJycb3o7.jpg