mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
loop: Fix FPS calculation
This commit is contained in:
parent
c3202b8e58
commit
0de9828e20
@ -156,15 +156,16 @@ func (c *runContext) adjustedNowWithAudio() int64 {
|
||||
|
||||
func (c *runContext) render(g GraphicsContext) error {
|
||||
fps := c.fps
|
||||
clockN := now()
|
||||
n := c.adjustedNowWithAudio()
|
||||
defer func() {
|
||||
// Calc the current FPS.
|
||||
if time.Second > time.Duration(n-c.lastFPSUpdated) {
|
||||
if time.Second > time.Duration(clockN-c.lastFPSUpdated) {
|
||||
return
|
||||
}
|
||||
currentFPS := float64(c.frames) * float64(time.Second) / float64(n-c.lastFPSUpdated)
|
||||
currentFPS := float64(c.frames) * float64(time.Second) / float64(clockN-c.lastFPSUpdated)
|
||||
c.updateFPS(currentFPS)
|
||||
c.lastFPSUpdated = n
|
||||
c.lastFPSUpdated = clockN
|
||||
c.frames = 0
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user