[ascii] Wrap Graphics in a handle

This commit is contained in:
2021-04-24 22:43:05 -06:00
parent dcb7d9f227
commit bd2b36bf1f
3 changed files with 5 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
(defnew [] [:Int a 5]) (defnew [] [:Int a 5])
(defmethod :Void update [:Float deltaSeconds] 0) (defmethod :Void update [:Float deltaSeconds] 0)
(defmethod :Void draw [:Graphics graphics] 0) (defmethod :Void draw [:Void->Graphics graphics] 0)

View File

@@ -17,4 +17,6 @@
(gameLogic.update deltaSeconds)) (gameLogic.update deltaSeconds))
(defmethod draw [] (defmethod draw []
(graphicsBackend.draw graphics)) (let [&mut changedGraphics false]
(gameLogic.draw (lambda [] (set changedGraphics true) graphics))
(when changedGraphics (graphicsBackend.draw graphics))))

View File

@@ -2,5 +2,5 @@ package asciilib;
interface GameLogic { interface GameLogic {
public function update(deltaSeconds:Float):Void; public function update(deltaSeconds:Float):Void;
public function draw(graphics:Graphics):Void; public function draw(graphicsHandle:() -> Graphics):Void;
} }