Frame rate independent game loop

Game development specific discussions.
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Post by dafhi »

works now!

[edit] 18 fps 5000 meta's GL
Last edited by dafhi on Oct 29, 2017 15:49, edited 1 time in total.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

There. Sorry for the inconvenience, mate.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:works now!
Modified the interface yourself? (preemptive strike hahaha) =D
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Post by dafhi »

paul doe wrote:
dafhi wrote:works now!
Modified the interface yourself? (preemptive strike hahaha) =D
downloaded .. my oop is very limited
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: Frame rate independent game loop

Post by h4tt3n »

paul doe wrote: Teaming up for something? Count me in! What kind of stuff you're interested in? 2D? 3D? And what kind of game, concretely? I need some fun (I'm sick of financial coding stuff) so this could be very interesting.
I would love to see your physics stuff. If time permits, I'll show you a simple implementation of a barebones 2D physics engine that uses Verlet. It's simplistic, but you can do mighty interesting stuff with it. It can be useful for debugging purposes, much like the 3D stuff in the thread that I pointed you before. Looking forward!
Hi Paul,

I am cleaning up a proof-of-concept demo version that will be posted very soon. In short, I have developed a 2D physics engine called SquishyPlanet that combines next-level soft-body physics and orbital mechanics. This serves as the backbone of my game Graveyard Orbit, which is an orbital mechanics puzzle in which the player needs to solve real-life space travel challenges, like placing cargo in orbit, moving from one planet to another, reaching a destination using as little fuel as possible, and hacking the levels using gravity assist, Oberth effect, roping through asteroid belts and what not. The soft body part is for girders, steel wires, vines, and space blobs. Since probably most people will find this too boring, I'm planning on adding a single/multi player dogfight mode where friends can blast each other out of the sky :-)

If you're into Verlet then I'm sure you'll like my home brewn soft body constraints - It's a very stable and rigid damped spring using sequential impulses and warm starting. I'll post some simple interactive demo doodles of it.

Anyway, long story short I'm looking for potential future partners and friends who share my interest and would like to develop this or similar games with me.

Cheers, Mike
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:works now!

[edit] 18 fps 5000 meta's GL
Wow. I scratch 10 fps with 1000 XD (yeah, the craptop I use to code sucks)
dafhi wrote:
paul doe wrote:
dafhi wrote:works now!
Modified the interface yourself? (preemptive strike hahaha) =D
downloaded .. my oop is very limited
Mmmm... I thought that you did it manually, we cross-posted as you can see. This is what your code was missing:

Code: Select all

...

	interface IRenderDevice extends object
		...
		
		declare abstract function setRes( byval as integer, byval as integer ) as integer
		declare abstract sub setRenderer( byval as IRenderer ptr )
		
		...
	end interface

...
Yeah, two declarations in the IRenderDevice interface. And this was the last commit (in interfaces.bi, of course). Seems that when the deltas are not too great, GitHub can't be bothered to commit them LOL!. Or perhaps my IC is not working properly. Will have to look at the issue. By the way, I will refactor glRenderDevice and glGameLoop to be adapters (wrappers) next, since they now employ a technique called 'copy&paste inheritance' XD Would you like me to explain the process here, so you can see how this works? Or any other thing that you may deem interesting. However you like.

See ya
Paul
Last edited by paul doe on Oct 29, 2017 20:48, edited 1 time in total.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

h4tt3n wrote: Hi Paul,

I am cleaning up a proof-of-concept demo version that will be posted very soon. In short, I have developed a 2D physics engine called SquishyPlanet that combines next-level soft-body physics and orbital mechanics. This serves as the backbone of my game Graveyard Orbit, which is an orbital mechanics puzzle in which the player needs to solve real-life space travel challenges, like placing cargo in orbit, moving from one planet to another, reaching a destination using as little fuel as possible, and hacking the levels using gravity assist, Oberth effect, roping through asteroid belts and what not. The soft body part is for girders, steel wires, vines, and space blobs. Since probably most people will find this too boring, I'm planning on adding a single/multi player dogfight mode where friends can blast each other out of the sky :-)
I'm not familiar with orbital mechanics, but will take a look. You're right, it does sound boring XD but I'm curious as to how you'd pull this off. I was thinking in more 'mundane' 2D physics, like Angry Birds or LBP. You caught me with my pants down on this one LOL
h4tt3n wrote: If you're into Verlet then I'm sure you'll like my home brewn soft body constraints - It's a very stable and rigid damped spring using sequential impulses and warm starting. I'll post some simple interactive demo doodles of it.

Anyway, long story short I'm looking for potential future partners and friends who share my interest and would like to develop this or similar games with me.
What I like about Verlet integration is its simplicity. You can make things that look and feel rather advanced, with very little coding and a minimum of fuss. Perhaps you already knew, but here is the de facto reference on Verlet: https://www.gamasutra.com/view/feature/ ... hysics.php

I would love to see your

Code: Select all

stuff, so when you're done, make sure that you tell me. Just quote whatever random crap I wrote, so I get the notification, dale? Catch you later.

Paul
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: Frame rate independent game loop

Post by h4tt3n »

I will, and yes I'm very familiar with Thomas Jacobsen's verlet paper - this brings fun memories from the old, original Hitman game in which he and his colleagues implemented it :-)
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:works now!

[edit] 18 fps 5000 meta's GL
By the way, dafhi. In 'loop comparison.bas', when you switch to DodiLoop, how many fps does it report? Asking because it should be 60. It is?
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Post by dafhi »

dodiloop 60. your version, even though reporting ~120, looks about 30. could be "physics " timestep or integer meta pos, although looking at vec2h i see floats .. ima grab my hot chocolate and see if i can figure this out.

okay found it

Code: Select all

m_ticksPerSecond = 30
lol
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:dodiloop 60. your version, even though reporting ~120, looks about 30. could be "physics " timestep or integer meta pos, although looking at vec2h i see floats .. ima grab my hot chocolate and see if i can figure this out.

okay found it

Code: Select all

m_ticksPerSecond = 30
lol
Haha very good. Change that to 60 if you wish the game to be updated at 60 fps. The rendering could go as fast as you hardware can handle, yet the updating of the game happens at 'm_ticksPerSecond' value. Want the loop code dissected here?
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Post by dafhi »

i'm more of a demo-style coder, but i've known about animation / physics .. first read about it from relsoft maybe? 2 other here also influenced the style that i use today: anonymous1337 and StoneMonkey

updated, from my post in the BasicCoder2 thread

Code: Select all

  var   iphys_fps = 1/89, phys_t = 0f
  var   ianim_fps = 1/24, anim_t = 0f
  var   tp = timer
 
  while inkey=""
    if anim_t <= 0 then
      screenlock
       ' ..
      screenunlock
      anim_t += ianim_fps
    endif
   
    sleep 1
   
    var t=timer, dt=t-tp
    tp=t
   
    anim_t -= dt
    phys_t += dt

    var frames=0
    while phys_t>0
      frames += 1
      phys_t -= iphys_fps
    wend
   
    var rate = pi*iphys_fps*frames*5
    incr axis.a0, .1*rate, twopi
    incr axis.a1, .011*rate, twopi
    
    '..
    
  wend
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:i'm more of a demo-style coder, but i've known about animation / physics .. first read about it from relsoft maybe? 2 other here also influenced the style that i use today: anonymous1337 and StoneMonkey
Very well, then. And yes, it was rel who first published about this. In the post (from 2014 IIRC) he used the implementation by Glenn Fiedler (the link to gafferongames.com that I posted before), while I use the implementation seen on koonsolo.com, by Koen Witters. Same problem, two solutions ;)
I'm currently refactoring the demo (minor changes in the interface) to be able to implement a simple physics demo.
dafhi wrote:updated, from my post in the BasicCoder2 thread
Which one?
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Post by dafhi »

The GL thread, page 4 near the top
Last edited by dafhi on Oct 30, 2017 16:13, edited 1 time in total.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Post by paul doe »

dafhi wrote:The GL thread, page 4 near the top. Nothing to write home about
Oh, right. The cube inside the sphere. Yeah I can see it now, hadn't worked through the code (even though the comment at the beginning clearly states this hahaha). Well then there's no mystery for you here =D
I asked because DodiLoop was reporting me 30, which isn't correct. Must be my box doing crappy things again :'(
Last edited by paul doe on Nov 01, 2017 11:29, edited 1 time in total.
Post Reply