[ascii] Wrap Graphics in a handle
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
(defnew [] [:Int a 5])
|
||||
|
||||
(defmethod :Void update [:Float deltaSeconds] 0)
|
||||
(defmethod :Void draw [:Graphics graphics] 0)
|
||||
(defmethod :Void draw [:Void->Graphics graphics] 0)
|
@@ -17,4 +17,6 @@
|
||||
(gameLogic.update deltaSeconds))
|
||||
|
||||
(defmethod draw []
|
||||
(graphicsBackend.draw graphics))
|
||||
(let [&mut changedGraphics false]
|
||||
(gameLogic.draw (lambda [] (set changedGraphics true) graphics))
|
||||
(when changedGraphics (graphicsBackend.draw graphics))))
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user