ZhengLinLei / stackblock.io

.io minigame
https://zhenglinlei.github.io/stackblock.io
Apache License 2.0
4 stars 2 forks source link

Warn to user if fps count is below than FPS/2 #59

Closed ZhengLinLei closed 11 months ago

ZhengLinLei commented 11 months ago

This problem was found in Apple users devices, but we want to extend it to all devices

        // if enough time has elapsed, draw the next frame
        if (GAME_.fpsCtrl.elapsed > GAME_.fpsCtrl.fpsInterval) {
            // Measure fps
            GAME_.fpsCtrl.mFps = Math.round(1000 / GAME_.fpsCtrl.elapsed);
            if (GAME_.fpsCtrl.mFps < GAME_.fpsCtrl.fps/2) {
                console.log('Lagggggggggggggggg');
            }
            // Get ready for next frame by setting then = now
            GAME_.fpsCtrl.then = GAME_.fpsCtrl.now - (GAME_.fpsCtrl.elapsed % GAME_.fpsCtrl.fpsInterval);
            // SAFE TO DRAW
            draw();
        }