diff --git a/projects/asciilib2/examples/death-trap/source/DeathTrapLogic.kiss b/projects/asciilib2/examples/death-trap/source/DeathTrapLogic.kiss index dd8caf1c..4d498d9d 100644 --- a/projects/asciilib2/examples/death-trap/source/DeathTrapLogic.kiss +++ b/projects/asciilib2/examples/death-trap/source/DeathTrapLogic.kiss @@ -1,4 +1,4 @@ (defnew [] [:Int a 5]) (defmethod :Void update [:Float deltaSeconds] 0) -(defmethod :Void draw [:Graphics graphics] 0) \ No newline at end of file +(defmethod :Void draw [:Void->Graphics graphics] 0) \ No newline at end of file diff --git a/projects/asciilib2/src/asciilib/Game.kiss b/projects/asciilib2/src/asciilib/Game.kiss index 6453a459..aaa203c8 100644 --- a/projects/asciilib2/src/asciilib/Game.kiss +++ b/projects/asciilib2/src/asciilib/Game.kiss @@ -17,4 +17,6 @@ (gameLogic.update deltaSeconds)) (defmethod draw [] - (graphicsBackend.draw graphics)) \ No newline at end of file + (let [&mut changedGraphics false] + (gameLogic.draw (lambda [] (set changedGraphics true) graphics)) + (when changedGraphics (graphicsBackend.draw graphics)))) \ No newline at end of file diff --git a/projects/asciilib2/src/asciilib/GameLogic.hx b/projects/asciilib2/src/asciilib/GameLogic.hx index e015230f..9c0df81b 100644 --- a/projects/asciilib2/src/asciilib/GameLogic.hx +++ b/projects/asciilib2/src/asciilib/GameLogic.hx @@ -2,5 +2,5 @@ package asciilib; interface GameLogic { public function update(deltaSeconds:Float):Void; - public function draw(graphics:Graphics):Void; + public function draw(graphicsHandle:() -> Graphics):Void; }