Hello,
To celebrate the start of the new wiki we will try to create a gameloop together as a community. Since this is a bit of an easy task and there are many gameloop around I will ask to not copy paste any existing gameloop. Instead, to get a wiki feel to that experiment, each person contributing can only add 1 line, remove 1 line or modify 1a few lines.
Good luck community!
[code]
public class GameLoopExperiment implements Runnable {
private final int framerate = 60;
private final long frameIntervalNanos = 1_000_000_000L / framerate;
public abstract void logic(int deltaTime);
public abstract void render();
public abstract boolean isRunning();
public void run() {
long lastFrameNanos;
boolean running = true;
while ( rthis.isRunning() ) {
... // loop?
lastFrameNanos = getNanoTime(); // TODO: Implement.
}
}
}
[/code]

Hello,

To celebrate the start of the new wiki we will try to create a gameloop together as a community. Since this is a bit of an easy task and there are many gameloop around I will ask to not copy paste any existing gameloop. Instead, to get a wiki feel to that experiment, each person contributing can only add, remove or modify a few lines.

We're going back to those entity systems now? The for-loops are odd, too. I'm on a tablet - wish I could participate.

An array named "entities" doesn't automatically mean "entity system". Ultimately you have a list of things to draw and loop over it. Maybe when I feel like my "turn" comes around again, I'll abstract it, god knows I'll replace the C-style loop. Unless of course someone beats me to it ...

Hi work not perfect(sleep not right on big numbers like fps 230), but I use him Also you can change “Sleep number” and see result And don’t set to low sleep time for thread, it may produce lags and eat performance ^^http://pastebin.java-gaming.org/82699379718

In my game loop code, the throttling mechanic is simply an 'entity' and not part of the main loop. To me it makes sense to implement that outside of the main loop as that gives you the opportunity to swap out different throttling strategies, even in runtime.For example, cut-scenes may require a hard-vsync'ed 30FPS, while during gameplay you might prefer to target 60fps and allow some screen tearing if things get hectic.(sorry for necro-ing an old thread)

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org