[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 {
|
class Main {
|
||||||
public static function newGame(logic:GameLogic) {
|
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() {
|
static function main() {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import asciilib.GameLogic;
|
|||||||
import asciilib.Game;
|
import asciilib.Game;
|
||||||
import asciilib.Graphics;
|
import asciilib.Graphics;
|
||||||
import asciilib.Colors;
|
import asciilib.Colors;
|
||||||
|
import asciilib.Assets;
|
||||||
import asciilib.backends.test.TestGraphicsBackend;
|
import asciilib.backends.test.TestGraphicsBackend;
|
||||||
|
|
||||||
class DrawOnlyWhenModifiedGameLogic implements GameLogic {
|
class DrawOnlyWhenModifiedGameLogic implements GameLogic {
|
||||||
@@ -13,9 +14,11 @@ class DrawOnlyWhenModifiedGameLogic implements GameLogic {
|
|||||||
|
|
||||||
public function new() {}
|
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) {
|
if (firstDraw) {
|
||||||
graphics().setLetter(0, 0, {char: "@", color: Colors.Red});
|
graphics().setLetter(0, 0, {char: "@", color: Colors.Red});
|
||||||
firstDraw = false;
|
firstDraw = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user