draw = function() {

fill(0, 255, 68); // start color

if (mouseIsPressed&&mouseX>50&&mouseX>250&&mouseY<150&&mouseX<400) {
fill(33, 112, 52); // click color
}
rect(50, 150, 250, 100); // the button

// The button text
fill(0, 0, 0);
textSize(30);
text("PRESS ME!", 93, 193);
};
what's wrong with my code

1 answer

There are a couple of issues with your code:

1. In the if statement condition, you have `mouseX>250` twice instead of using `mouseY` for the second condition. It should be `mouseY<150` instead of `mouseX>250`.

2. In the fill function for the button click color, you have `33, 112, 52` instead of `0, 112, 52`. It should be `fill(0, 112, 52)` for the click color.

After making these changes, your code should work as expected.
Similar Questions
  1. draw = function() {fill(0, 255, 68); // start color if (mouseIsPressed&&mouseX>50&&mouseX>250&&mouseY<150&&mouseX<400) {
    1. answers icon 1 answer
  2. draw = function() {fill(0, 255, 68); // start color if (mouseIsPressed) { fill(33, 112, 52); // click color } rect(50, 150, 250,
    1. answers icon 1 answer
  3. draw = function() {background(165, 219, 162); fill(255, 254, 222); rect(20, 100, 364, 200); fill(0, 0, 0); textSize(20);
    1. answers icon 1 answer
  4. What does a snipping tool allow you to do?(1 point) Responses draw shapes, such as squares or circles draw shapes, such as
    1. answers icon 11 answers
more similar questions