[ascii] fix test backend compatibility
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package asciilib.backends.test;
|
||||
|
||||
import asciilib.AssetsBackend;
|
||||
import sys.io.File;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class TestAssetsBackend implements AssetsBackend {}
|
@@ -0,0 +1,3 @@
|
||||
(defmethod new [] 0)
|
||||
|
||||
(defmethod loadText [filePath] (File.getContent filePath))
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user