Files
kiss-vscode/projects/asciilib2/src/asciilib/Game.kiss

26 lines
869 B
Plaintext

(defNew [title
width
height
letterWidth
letterHeight
_gameLogic
assetsBackend
_graphicsBackend]
// TODO the type annotation on this line feels like a bit much, but is necessary:
[:Graphics graphics (new Graphics width height)
:GameLogic gameLogic _gameLogic
:Assets assets (new Assets assetsBackend)
:GraphicsBackend graphicsBackend _graphicsBackend]
(graphicsBackend.initialize title width height letterWidth letterHeight)
(gameLogic.initialize assets))
(method update [:Float deltaSeconds]
(gameLogic.update this deltaSeconds))
(method draw []
(let [&mut changedGraphics false]
(gameLogic.draw (lambda [] (set changedGraphics true) graphics) assets)
(when changedGraphics (graphicsBackend.draw graphics))))