I am trying to write a method that loops and repeatedly calls other methods. Inside the loop, there is one place that you need to pause and wait for the user to press one of several buttons in the graphical interface. I used to do this with command line code, but I'm not sure how to wait and check if the buttons were pressed. If someone helped me, I would be very grateful. Below is an example of what I would like to do.
While(MoreLeftToD0){
Method1();
WaitForUserToClickButton();
If(Button1 was clicked)
ProcessWithButton1();
else
ProcessWithButton2(); }
EDIT: I think a little more information might help, and maybe I'm thinking about it wrong. I am trying to create a simple game in which 2 players 0, 1 or 2 of these players can be bots, and others (others) will be people. I want a base Player class that has Human and Bot classes that inherit from Player.
A loop for the playing field, and I just want to call CurrentPlayer.GetMove (gameBoard), which for the bot will transmit the playing field and allow them to decide the move. However, if this is a person, GetMove () must wait until the user clicks a button in the graphical interface, indicating what they want to do on the board, and then process the click accordingly.
Hope this reveals the goal a bit. If there is a better way to do this, I would like to hear suggestions. Thanks!
source
share