Hi~ thanks your Demo ,but i got some problem on it
In your Example 3-6 the plant need to run by hand
if (eventKey == Keyboard.KEY_D && Keyboard.isKeyDown(Keyboard.KEY_D)) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ||
Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
day = (day - 10) % 360;
} else {
day = (day + 10) % 360;
}
}
...etc
and i want the plant run by itself
this is my code:
protected void logic(long timeDelta) {
day = (day + 10) % 360;
year = (year + 5) % 360;
}
the Base class had been set
protected void run() {
while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) {
now = System.currentTimeMillis();
timeDelta = now - lastTime;
lastTime = now;
if (Display.isVisible()) {
logic(timeDelta);
render();
} else {
if (Display.isDirty()) {
render();
}
try {
Thread.sleep(500); } catch (InterruptedException ex) {
}
}
Display.update();
}
}
but it's don't work.... plant run so fast...
i also check the FullScreenWindowedTest (
http://lwjgl.org/demos.php)
while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) {
if (Display.isVisible()) {
// check keyboard input
processKeyboard();
// do "game" logic, and render it
logic();
render();
} else {
// no need to render/paint if nothing has changed (ie. window
// dragged over)
if (Display.isDirty()) {
render();
}
// don't waste cpu time, sleep more
try {
Thread.sleep(100); } catch (InterruptedException inte) {
}
}
// Update window
Display.update();
}
the FullScreenWindowedTest runs well but my code is not
why?