FUNGICIDE - Retro Game Competition Entry

Started by Scaremonger, January 19, 2018, 23:40:38

Previous topic - Next topic

Derron

#15
Works fine here ... constant 59fps.


@ 16.7 and 16
Keyframe :+ ... 16
nextFrame :+ ... 16.7

Every second loop you already skip one frame (16 + 16 = 32, 16.7+16.7=33.4) so input is not done with 60fps but a little different value. Should not really matter :p


Your loop seems to say: call "game.update()" as often as possible? Maybe the "jitter/lag" was coming from some logic code running recursively - or with wrong valus ("for x:int =0 to bigvalue").
To avoid cpu hogging I limit updates too - so I have two accumulators: update and render. Each fill up to their needs (if any). Also it is more common to have updates fixed rate and renders "flexible" (updates define positions for collisions, define states ... renders only define where they actually are to draw and then drawing them).


bye
Ron

Scaremonger

Quote from: Derron on February 03, 2018, 15:09:22
@ 16.7 and 16
Keyframe :+ ... 16
nextFrame :+ ... 16.7

Every second loop you already skip one frame (16 + 16 = 32, 16.7+16.7=33.4) so input is not done with 60fps but a little different value. Should not really matter :p

Lol. That was me trying to figure out how often I should check for keypresses and I never got around to finding the best value.

Quote from: Derron on February 03, 2018, 15:09:22
Your loop seems to say: call "game.update()" as often as possible? Maybe the "jitter/lag" was coming from some logic code running recursively - or with wrong valus ("for x:int =0 to bigvalue").
To avoid cpu hogging I limit updates too - so I have two accumulators: update and render. Each fill up to their needs (if any). Also it is more common to have updates fixed rate and renders "flexible" (updates define positions for collisions, define states ... renders only define where they actually are to draw and then drawing them).

Good point. My loop does an update of every sprite and graphic each loop and redraw (render) at 60/s. I should be limiting the updates as there is no benefit moving something a fraction of a pixel, but I think my biggest problem is glaringly obvious now. I've missed a delay in the loop which will likely be causing a bit of CPU hogging.

I will re-work the game loop before I release a revision. Many thanks for the review; Much appreciated.

Si...

meems

got major lag spikes, sometimes when shooting laser