Files
voxelotl-engine/Sources/Voxelotl/GameDelegate.swift

31 lines
659 B
Swift
Raw Normal View History

2024-08-13 08:38:21 +10:00
public protocol GameDelegate {
func create(_ renderer: Renderer)
2024-08-13 08:38:21 +10:00
func fixedUpdate(_ time: GameTime)
func update(_ time: GameTime)
func draw(_ renderer: Renderer, _ time: GameTime)
func resize(_ frame: Rect<Int>)
2024-08-13 08:38:21 +10:00
}
public extension GameDelegate {
func fixedUpdate(_ time: GameTime) {}
func update(_ time: GameTime) {}
func resize(_ frame: Rect<Int>) {}
2024-08-13 08:38:21 +10:00
}
public struct GameTime {
let total: Duration
let delta: Duration
}
extension Duration {
var asFloat: Double {
Double(components.seconds) + Double(components.attoseconds) * 1e-18
}
}
extension Float {
public init(_ value: Duration) {
self = Float(value.asFloat)
}
}