Here is a loop:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| 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:
1 2 3 4 5 6 7 8 9 10 11 12
| 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:
1 2 3 4 5 6 7 8 9 10 11
| 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)) { } |