Here is a loop:
public static void main(String[] args) {
Main main = new Main();
while (!main.exit) {
main.game.changeResolution(main.frame.getWidth(), main.frame.getHeight());
main.input();
main.logic();
main.render();
try {
Thread.sleep(main.timeToSleep);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.exit(0);
}
Sending Input to Game:
private void input() {
if (mouseClick != null) {
getDeviceCoords(mouseClick);
game.mouseClick(mouseButtonPressed, mouseClick);
mouseClick = null;
}
if (mouseLocation != null) {
getDeviceCoords(mouseClick);
game.mouseLocation(mouseLocation);
}
}
After this you may want to create class or a collection that stores the inputs and the process them within the logic.
Like so:
if(!plays.isEmpty())
for (Point click : plays)
world.playCard(player, click);
if (!discards.isEmpty())
for (Point click : discards)
world.discardCard(player, click);
if(turn.isPlayersTurn(ai)) {
//TODO: add more advanced AI
}