Results 1 to 1 of 1
  1. #1
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default 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.

    Java Code:
    for(double i=0; true; i ++) {
    			try {
    				Thread.sleep(100);
    			}
    			catch (InterruptedException e) {}
    			....
                            repaint();
    		}
    Any advice? Thanks in advance.
    Last edited by CORNandTOOTHPICK; 02-17-2013 at 06:02 PM.

Similar Threads

  1. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  2. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  3. Program skips "If" code and goes straight to "Else"
    By Logik22 in forum New To Java
    Replies: 12
    Last Post: 01-21-2012, 05:40 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •