rearrange some sources

This commit is contained in:
2024-09-02 19:13:29 +10:00
parent fc50f0b350
commit d35de84221
4 changed files with 10 additions and 10 deletions

View File

@ -0,0 +1,20 @@
import Foundation
public struct FPSCalculator {
private var _accumulator = Duration.zero
private var _framesCount = 0
public mutating func frame(deltaTime: Duration, result: (_ fps: Int) -> Void) {
self._framesCount += 1
self._accumulator += deltaTime
if self._accumulator >= Duration.seconds(1) {
result(self._framesCount)
self._framesCount = 0
self._accumulator = .init(
secondsComponent: 0,
attosecondsComponent: self._accumulator.components.attoseconds)
}
}
}