added textRepresentation to Layer
This commit is contained in:
parent
e0d4844890
commit
ca79714e8d
@ -1,5 +1,7 @@
|
||||
package lib.turtle;
|
||||
|
||||
typedef Block = Bool;
|
||||
|
||||
abstract Structure(Array<Layer>) from Array<Layer> {
|
||||
public inline function getLayer(i:Int):Layer {
|
||||
return this[i];
|
||||
@ -10,8 +12,8 @@ abstract Structure(Array<Layer>) from Array<Layer> {
|
||||
}
|
||||
}
|
||||
|
||||
abstract Layer(Array<Array<Bool>>) from Array<Array<Bool>> {
|
||||
public inline function get(x:Int, y:Int):Bool {
|
||||
abstract Layer(Array<Array<Block>>) from Array<Array<Block>> {
|
||||
public inline function get(x:Int, y:Int):Block {
|
||||
return this[y][x];
|
||||
}
|
||||
|
||||
@ -22,4 +24,19 @@ abstract Layer(Array<Array<Bool>>) from Array<Array<Bool>> {
|
||||
public inline function height():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public function getTextRepresentation():String {
|
||||
var str = "";
|
||||
for (y in 0...height()) {
|
||||
for (x in 0...width()) {
|
||||
if (get(x, y)) {
|
||||
str += "X";
|
||||
} else {
|
||||
str += " ";
|
||||
}
|
||||
}
|
||||
str += "\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user