How do I make time?
Posted
by
SystemNetworks
on Game Development
See other posts from Game Development
or by SystemNetworks
Published on 2012-10-05T06:15:03Z
Indexed on
2012/10/05
9:50 UTC
Read the original article
Hit count: 328
I wanted to output a text for a certain amount of time. One way is to use threads. Are there any other ways? I can't use threads for slick2d. This is my code when I use threads for slick:
package javagame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import java.util.Random;
import org.newdawn.slick.Input;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import org.lwjgl.input.Mouse;
public class thread1 implements Runnable {
String showUp;
int timeLeft;
public thread1(String s)
{
s = showUp;
}
public void run(Graphics g)
{
try {
g.drawString("%s is sleeping %d", 500, 500);
Thread.sleep(timeLeft);
g.drawString("%s is awake", 600,600);
} catch(Exception e) { }
}
@Override
public void run() {
// TODO Auto-generated method stub
run();
}
}
It auto generates a new run()
And also when I call it to my main class it has stack overflow!
© Game Development or respective owner