please format code with </> button * homework policy * asking questions
I am trying to make a multidimensional array, storing my array of images on one and states on the left side and storing the images on the right side in the other. I am unsure of how to update my buttons and I am just not sure how I would do that with the code I have already made and I do not know where I would put the conditional to render my image that corresponds to the button pressed.
</>let buttons = , buttonStates = [true,false];
let imgs = ;
function preload() {
function setup() {
createCanvas(800, 800);
buttons = [createButton(),createButton(),createButton(),createButton("),createButton(),createButton()];
buttons[0].style(‘font-type’, ‘Times’);
buttons[0].style(‘font-size’, ‘12px’);
buttons[0].style(‘background-color’ ,‘#6CCDE5’);
buttons[0].position(810,0);
buttons[0].mousePressed(_=> {
buttonStates.forEach((state,index) => {
buttonStates[index] = false;
});
buttonStates[1] = true;
});
buttons[1].style(‘font-type’, ‘Times’);
buttons[1].style(‘font-size’, ‘12px’);
buttons[1].style(‘background-color’ ,‘#6CCDE5’);
buttons[1].position(810,30);
buttons[1].mousePressed(_=> {
buttonStates.forEach((state,index) => {
buttonStates[index] = false;
});
buttonStates[0] = true;
});
buttons[2].style(‘font-type’, ‘Times’);
buttons[2].style(‘font-size’, ‘12px’);
buttons[2].style(‘background-color’ ,‘#6A9F34’);
buttons[2].position(810,60);
buttons[2].mousePressed(_=> {
buttonStates.forEach((state,index) => {
buttonStates[index] = false;
});
buttonStates[1] = true;
});
buttons[3].style(‘font-type’, ‘Times’);
buttons[3].style(‘font-size’, ‘12px’);
buttons[3].style(‘background-color’ ,‘#6A9F34’);
buttons[3].position(810,90);
buttons[3].mousePressed(_=> {
buttonStates.forEach((state,index,imgs) => {
buttonStates[index] = false;
});
buttonStates[1] = true;
});
buttons[4].style(‘font-type’, ‘Times’);
buttons[4].style(‘font-size’, ‘12px’);
buttons[4].style(‘background-color’ ,‘#E6B786’);
buttons[4].position(810,120);
buttons[4].mousePressed(_=> {
buttonStates.forEach((state,index) => {
buttonStates[index] = false;
});
buttonStates[0] = true;
});
buttons[5].style(‘font-type’, ‘Times’);
buttons[5].style(‘font-size’, ‘12px’);
buttons[5].style(‘background-color’ ,‘#E6B786’);
buttons[5].position(810,150);
buttons[5].mousePressed(_=> {
buttonStates.forEach((state,index) => {
buttonStates[index] = false;
});
buttonStates[1] = true;
});
}
function draw() {
background(220);>/<