[ascii] test loading surfaces

This commit is contained in:
2021-04-26 19:52:13 -06:00
parent 1c71a9cc0a
commit f1fdd1f4cc
2 changed files with 226 additions and 0 deletions

View File

@@ -0,0 +1,184 @@
COLORS
! 128 128 255
" 255 255 255
# 98 49 0
$ 159 80 0
% 41 41 41
& 128 128 128
' 106 106 106
( 0 0 0
INFO CODES
! .
" POINT_screen
SIZE
68 33
CHARACTERS
test text on laptop
BACKGROUND COLORS
!!!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!!!!
!!!!%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%!!!!
!!!!%&''''''''''''''''''''''''''''''''''''''''''''''''''''''''&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&'(((((((((((((((((((((((((((((((((((((((((((((((((((((('&%!!!!
!!!!%&''''''''''''''''''''''''''''''''''''''''''''''''''''''''&%!!!!
!!!!%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%!!!!
!!!!%''''''''''''''''''''''''''''''''''''''''''''''''''''''''''%!!!!
!!!%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%!!!
!!!%&&''''''''''''''''''''''''''''''''''''''''''''''''''''''''&&%!!!
!!%&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&%!!
!!%&&''''''''''''''''''''''''''''''''''''''''''''''''''''''''''&&%!!
!%&&'&&&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&%!
!%&&''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''&&%!
%&&'&&&&&'&&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&'&&&&&'&&%
%&&''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''&&%
CHARACTER COLORS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00001111111111111111111111111111111111111111111111111111111111110000
00011111111111111111111111111111111111111111111111111111111111111000
00011111111111111111111111111111111111111111111111111111111111111000
00111111111111111111111111111111111111111111111111111111111111111100
00111111111111111111111111111111111111111111111111111111111111111100
01111111111111111111111111111111111111111111111111111111111111111110
01111111111111111111111111111111111111111111111111111111111111111110
11111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111
SPECIAL INFO
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!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-0,0 +1,42 @@
package cases;
import utest.Test;
import utest.Assert;
import asciilib.GameLogic;
import asciilib.Game;
import asciilib.Graphics;
import asciilib.Colors;
import asciilib.Assets;
import asciilib.Surface;
class LoadSurfaceGameLogic implements GameLogic {
public function new() {}
public function initialize(assets:Assets) {
assets.loadSurface("laptop", "assets/laptop.srf");
}
public function update(game:Game, deltaSeconds:Float):Void {}
public function draw(graphics:Void->Graphics, assets:Assets):Void {}
}
class LoadSurfaceTestCase extends Test {
function testLoadSurface() {
var game = Main.newGame(new LoadSurfaceGameLogic());
var laptop = game.assets.getSurface("laptop");
var cornerColor = laptop.getBackgroundColor(0, 0);
Assert.equals(128, cornerColor.r);
Assert.equals(128, cornerColor.g);
Assert.equals(255, cornerColor.b);
Assert.isFalse(laptop.isCellOpaque(0, 0));
var topColor = laptop.getBackgroundColor(6, 0);
Assert.equals(41, topColor.r);
Assert.isTrue(laptop.isCellOpaque(6, 0));
Assert.equals(".", laptop.getSpecialInfo(0, 0));
Assert.equals("POINT_screen", laptop.getSpecialInfo(8, 4));
Assert.equals("t", laptop.getLetter(17, 6).char);
Assert.equals(" ", laptop.getLetter(18, 6).char);
}
}