68 lines
1.3 KiB
Swift
68 lines
1.3 KiB
Swift
import Foundation
|
|
import simd
|
|
import JolkEngine
|
|
|
|
|
|
@main struct Program
|
|
{
|
|
static func main()
|
|
{
|
|
Application(
|
|
application: CavesOfJolk(),
|
|
config: ApplicationConfiguration(
|
|
resizable: true,
|
|
vSync: .on,
|
|
windowWidth: 1280,
|
|
windowHeight: 720,
|
|
title: "Caves of Swift",
|
|
bundle: Bundle.module)
|
|
).run()
|
|
}
|
|
}
|
|
|
|
class CavesOfJolk: ApplicationImplementation
|
|
{
|
|
private lazy var scene = Scene1()
|
|
//private lazy var scene = CaveScene()
|
|
private var aspect: Float = 0
|
|
private var frameCount = 0
|
|
private var frameTimer: Float = 1
|
|
|
|
func create(render: inout Renderer)
|
|
{
|
|
scene.setup(render: &render)
|
|
}
|
|
|
|
func loadContent(content: inout ContentManager) throws
|
|
{
|
|
try scene.loadContent(content: &content)
|
|
}
|
|
|
|
func resize(width: Int, height: Int)
|
|
{
|
|
aspect = Float(width) / Float(height)
|
|
print(aspect)
|
|
}
|
|
|
|
func update(deltaTime: Float)
|
|
{
|
|
scene.update(deltaTime: deltaTime)
|
|
|
|
frameCount += 1
|
|
frameTimer -= deltaTime
|
|
if frameTimer <= 0
|
|
{
|
|
print("FPS: \(frameCount)")
|
|
frameCount = 0
|
|
frameTimer += 1.0
|
|
}
|
|
}
|
|
|
|
func draw(render: inout Renderer, deltaTime: Float)
|
|
{
|
|
if Input.instance.keyboard.keyPressed(.w, repeat: true) { render.wireframe = !render.wireframe }
|
|
|
|
scene.draw(render: &render, deltaTime: deltaTime, aspectRatio: aspect)
|
|
}
|
|
}
|