Just a quick beginner question
in
Programming Questions
•
1 month ago
Hello, I´m just getting started with processing and I thought I would try doing a sort of super simplistic "Trivia" , I want to ask a question and have 3 answers in the bottom, the background is the question, while a three different images each have an answer corresponding to a key. If the answer is correct, 2 of the images should dim while the correct one will stay clear.
So far I managed to add all three images and get them to react to the key commands, however, when one of the keys is pressed, all three images change properties instead of just 2. This is my main question, since I haven´t started the code for adding another set of answers and another question.
This is the code so far:
PImage bg;
int y;
PImage a;
PImage b;
PImage c;
void setup() {
size(853, 480);
bg = loadImage("Pregunta1.jpg");
a = loadImage("respuestaA.jpg");
b = loadImage("respuestaB.jpg");
c = loadImage("respuestaC.jpg");
}
void draw() {
background(bg);
stroke(226, 204, 0);
line(0, y, width, y);
y++;
if (y > height) {
y = 0;
}
image(a,5,320);
image(b,305,320);
image(c,605,320);
}
void keyPressed() {
if (key == 'a')
{
tint(a)=tint(200);
}
if(key == 'b')
{
image(b,305,320);
tint(50);
}
if(key == 'c')
{
image(c,605,320);
tint(50);
}
}
1