diff --git a/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.hx b/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.hx new file mode 100644 index 00000000..4712445c --- /dev/null +++ b/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.hx @@ -0,0 +1,7 @@ +package asciilib.backends.test; + +import asciilib.AssetsBackend; +import sys.io.File; + +@:build(kiss.Kiss.build()) +class TestAssetsBackend implements AssetsBackend {} diff --git a/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.kiss b/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.kiss new file mode 100644 index 00000000..89627776 --- /dev/null +++ b/projects/asciilib2/src/asciilib/backends/test/TestAssetsBackend.kiss @@ -0,0 +1,3 @@ +(defmethod new [] 0) + +(defmethod loadText [filePath] (File.getContent filePath)) \ No newline at end of file diff --git a/projects/asciilib2/test/src/Main.hx b/projects/asciilib2/test/src/Main.hx index 20c94545..58256560 100644 --- a/projects/asciilib2/test/src/Main.hx +++ b/projects/asciilib2/test/src/Main.hx @@ -8,7 +8,7 @@ import asciilib.backends.test.*; class Main { public static function newGame(logic:GameLogic) { - return new Game("Test game", 100, 40, 8, 12, logic, new TestGraphicsBackend()); + return new Game("Test game", 100, 40, 8, 12, logic, new TestAssetsBackend(), new TestGraphicsBackend()); } static function main() { @@ -17,4 +17,4 @@ class Main { Report.create(runner); runner.run(); } -} \ No newline at end of file +} diff --git a/projects/asciilib2/test/src/cases/DrawOnlyWhenModifiedTestCase.hx b/projects/asciilib2/test/src/cases/DrawOnlyWhenModifiedTestCase.hx index 60787044..5fdafe14 100644 --- a/projects/asciilib2/test/src/cases/DrawOnlyWhenModifiedTestCase.hx +++ b/projects/asciilib2/test/src/cases/DrawOnlyWhenModifiedTestCase.hx @@ -6,6 +6,7 @@ import asciilib.GameLogic; import asciilib.Game; import asciilib.Graphics; import asciilib.Colors; +import asciilib.Assets; import asciilib.backends.test.TestGraphicsBackend; class DrawOnlyWhenModifiedGameLogic implements GameLogic { @@ -13,9 +14,11 @@ class DrawOnlyWhenModifiedGameLogic implements GameLogic { public function new() {} - public function update(deltaSeconds:Float):Void {} + public function initialize(assets:Assets) {} - public function draw(graphics:Void->Graphics):Void { + public function update(game:Game, deltaSeconds:Float):Void {} + + public function draw(graphics:Void->Graphics, assets:Assets):Void { if (firstDraw) { graphics().setLetter(0, 0, {char: "@", color: Colors.Red}); firstDraw = false; @@ -33,4 +36,4 @@ class DrawOnlyWhenModifiedTestCase extends Test { game.draw(); Assert.equals(1, graphicsBackend.drawCalled); } -} \ No newline at end of file +}