Gameloop experiment

That’s way beyond the scope of this wiki entry. It’s pretty much doomed, hence the ‘experiment’ !

I’m very interested to see what cruft we can create, as a community.

Serious attempts at making a game loop probably should have their own articles.

In that case I’m surprised you’re so unambitious. We should be using this thread to build a MMORPG!

:persecutioncomplex: … the new github… :persecutioncomplex: ::slight_smile: :point: :stuck_out_tongue:

Moving lastFrameNanos into a local? That’s going to make it interesting to calculate the delta between run() calls. It’s already gotten schizophrenic.

(EDIT: oh i’m a dip. Runnable. As in run doesn’t return. The loop made that much obvious).

Why call it more than once? Minimalism ftw.

I can’t change anything. It just gives me “Loading…” all the time :frowning:
EDIT: only when using quick edit.

Hm… maybe it’s [quick edit] that’s broken for wiki entries. Just click [modify] instead, it should work.

Just one line? I’d like to add a constructor with the framerate as parameter.

EDIT: And what if you want to rename something? That usually requires more than one line to edit. Because obviously ‘framerate’ should be called ‘targetFrameRate’ :slight_smile:

don’t get me wrong… joke :smiley:

It’s a wiki, I just changed the rules! :point:

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

Why don’t say only logical 1-lines okey?
So you only are allowed to write 1 “;” per edit/person?

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 …

If you notice the current rules, it’s a “few” lines now.

Isn’t that going into game logic, and beyond the scope of the gameloop?

I agree the C-style loop is weird for iterations. Last time I looked it was invalid code though, which is… worse.

It’s just to give you the idea. I wouldn’t take it seriously. Maybe we can write an actual runnable program for an implementation (bunch of bouncing balls maybe).

I wouldn’t be against it. We can make a smaller nested class to hold position, radius, color, and update and render methods.

I love the ball idea :slight_smile:

btw we are still missing the thread.sleep() to follow the framerate

I call it Syncronize =)

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

Also I have this mini class for debug purposes(and now only ;)), sometimes tired write System…
http://pastebin.java-gaming.org/e0826199917

Here’s a Ball :stuck_out_tongue:
http://pastebin.java-gaming.org/ee082069919

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)