1
Hello, I’m making a game Genius, the one who needs to select the colors in the right order...
And I’m having a little trouble with the player’s turn...
public void jogadorJoga(){
}
In this method I need to make the program wait for the user to press the button, and so check if the selected color is correct, but the part of make the program wait I have no idea how it could be. I was thinking of creating a variable to save the selected color, and then check if it’s right, someone has a hint?
Edit:
I created a game in which he creates a sequence of colors and this sequence is added in a "List", then shows the sequence flashing the buttons in a swing with 4 buttons (blue, red, green, yellow)
now, the part that I need to do that I’m not getting is the player part, he needs to select the colors in the right order, however I got lost around, I don’t know how does the program expect to receive clicks from the player,my idea, I would have to do a while(true) and when the button is pressed it comes out of that while and saves the color in a variable? I don’t know the right way to do this. I’m very beginner in java.
Your question is too wide. As I saw that you are learning (by your other question), it would be more interesting to first try to understand the fundamentals of language (if you are starting now) before falling into such a project, which may have a level of complexity that can even hinder your learning.
– user28595
yes, the other question was very strange, sometimes I confuse several things, and I have difficulty with this, I will have to study this part well, but I have a job to deliver, could you take a look again? I edited the question.
– Kelvin Crepaldi
The question remains broad. In swing there is no need to loop to expect user action, the functioning of the API is to stay under a thread running all the time, with the concept of listeners, who are "listening" actions on the interface (as long as you have programmed some, of course)
– user28595
You can start by seeing some questions under the tag swing, to see how it works, to take some solutions and to play with them, to see create more affinity with the API, and then yes, to start doing this, it will be much more constructive, because you will be playing with something that already has certain knowledge of how it works, even if it is a basic knowledge.
– user28595
Hm I got it, I was looking at it the wrong way. I’ll do what you said, I have a lot of free time, and this will help me. Thank you very much.
– Kelvin Crepaldi