display image based on user input
in
Programming Questions
•
2 months ago
Hello, I'm working on a basic game concept, but I'm having trouble with taking user input (text.)
I want the game to ask a question, then the user answers, if the answer is correct display one image or animation and if its wrong display a different one.
I want the game to ask a question, then the user answers, if the answer is correct display one image or animation and if its wrong display a different one.
So I have all these png images that are parts of animations and i want to display one according to the text input, later i want to make an animation class and display that.
heres the code now, it takes user input and saves it ( I copied it from the Daniel Shiffman book)
should i edit the draw loop or the key pressed loop?? Any help would be really appreciated thanks!
void draw() {
background(background);
//image(normal, 185, -140);
image(normal, 210, 200, normal.width/2, normal.height/2);
textFont(f);
textSize(60);
// character text
text(question1, 50, 50);
// user text
text(typing,50,100);
text(saved,50,150);
}
void keyPressed(){
if (key == '\n' ) {
saved = typing;
typing = "";
} else {
typing = typing + key;
}
}
so im trying to do something like
while(question = question1)
if ( user text = correct anwser)
display good image;
else
display bad image;
how would i make it "read" the user text and then do something based on that??
I can put all the code here, but i figured the rest isn't really important it just loads a bunch of images and strings, next I want to display different images and strings based on the text
please help :)
1