private static int millis_per_tick = 1;
public void run()
{
// While not stop do
while(true)
{
Thread t = Thread.currentThread();
long startTime, timeTaken;
startTime = System.currentTimeMillis();
act();
timeTaken = System.currentTimeMillis() - startTime;
if(timeTaken < millis_per_tick )
{
try
{
Thread.sleep(millis_per_tick-timeTaken );
}
catch(InterruptedException ex)
{}
}
The thread.sleep method does not accept double values only float and integer. But i need a value under 1.
In Space
public void act()
{
ListIterator<Body> iterator = bodies.listIterator();
while (iterator.hasNext())
{
Body body = iterator.next();
body.wirkenKraefte();
body.move();
}
spaceGUI.repaint();