Constantly "Awake" program
Hello,
I am trying to make a 2D map. The map consists of many tiles of different colors (white for ground, green for trees, etc.) I want to know how to make it keep animating without stop AND have a certain tile move by actionlistener of the keyboard simultaneously. (In other words, tiles are moving randomly, and whenever you click to move, a specific tile moves in the directly you indicated. I want the movement of the tiles and the movement of the user tile to be independent. So far I have this, but If I make a user movement, the tile I moved "waits" till the repaint() occurs.
Code:
for(double i=0; true; i ++) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {}
....
repaint();
}
Any advice? Thanks in advance.