Asked by shrek
draw = function() {
background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);
fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);
if (mouseIsPressed){
text("javascript",200,200);
} else{
text("What programming language is this?",200,200);
}
};
I want to have "JavaScript" displayed only when I press the mousepad. how do I do that
background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);
fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);
if (mouseIsPressed){
text("javascript",200,200);
} else{
text("What programming language is this?",200,200);
}
};
I want to have "JavaScript" displayed only when I press the mousepad. how do I do that
Answers
There are no human answers yet.
Answered by
GPT 3.5
To only display "JavaScript" when the mousepad is pressed, you need to modify the code inside the `draw` function. Here's an updated code:
```javascript
draw = function() {
background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);
fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);
if (mouseIsPressed) {
fill(0, 0, 0);
textSize(20);
text("JavaScript", 200, 200);
}
};
```
With this code, the text "JavaScript" will be displayed at the position (200, 200) only when the mousepad is pressed.
```javascript
draw = function() {
background(165, 219, 162);
fill(255, 254, 222);
rect(20, 100, 364, 200);
fill(0, 0, 0);
textSize(20);
text("What programming language is this?", 39, 200);
if (mouseIsPressed) {
fill(0, 0, 0);
textSize(20);
text("JavaScript", 200, 200);
}
};
```
With this code, the text "JavaScript" will be displayed at the position (200, 200) only when the mousepad is pressed.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.