lib/gamnit: initialize `current_fps` to `maximum_fps`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 16 Apr 2016 16:06:07 +0000 (12:06 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 20 May 2016 19:22:41 +0000 (15:22 -0400)
This lets a program use `current_fps` right from the beginning and
gives a value which is somewhat realistic (vs returning 0).

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/limit_fps.nit

index a300b54..f16609f 100644 (file)
@@ -29,8 +29,8 @@ redef class App
 
        # Current frame-rate
        #
-       # Updated each 5 seconds.
-       var current_fps = 0.0
+       # Updated each 5 seconds, initialized at the value of `maximum_fps`.
+       var current_fps: Float = maximum_fps is lazy
 
        redef fun frame_full
        do
@@ -47,7 +47,7 @@ redef class App
        private var frame_count = 0
 
        # Deadline used to compute `current_fps`
-       private var frame_count_deadline = 0
+       private var frame_count_deadline = 5
 
        # Check and sleep to maintain a frame-rate bellow `maximum_fps`
        #