[asciilib] setting up graphics backend

This commit is contained in:
2021-04-24 18:50:08 -06:00
parent 064715939a
commit 7a5c47a951
6 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
package asciilib;
@:build(kiss.Kiss.build("src/asciilib/Game.kiss"))
class Game {}

View File

@@ -0,0 +1,18 @@
(defnew [:String title
:Int width
:Int height
:Int letterWidth
:Int letterHeight
:GameLogic gameLogic
:GraphicsBackend _graphicsBackend]
[graphics (new Graphics width height)
logic gameLogic
graphicsBackend _graphicsBackend]
(graphicsBackend.initialize title width height letterWidth letterHeight))
(defmethod update [:Float deltaSeconds]
(gameLogic.update deltaSeconds))
(defmethod draw []
(graphicsBackend.draw graphics))

View File

@@ -0,0 +1,6 @@
package asciilib;
interface GameLogic {
public function update(deltaSeconds:Float):Void;
public function draw(graphics:Graphics):Void;
}

View File

@@ -0,0 +1,4 @@
package asciilib;
@:build(kiss.Kiss.build("src/asciilib/Graphics.kiss"))
class Graphics {}

View File

@@ -0,0 +1,2 @@
(defnew [width height]
[surface (new Surface width height)])

View File

@@ -0,0 +1,6 @@
package asciilib;
interface GraphicsBackend {
function initialize(title:String, width:Int, height:Int, letterWidth:Int, letterHeight:Int):Void;
function draw(graphics:Graphics):Void;
}