improved turtle Printer
This commit is contained in:
parent
be89ca12bd
commit
f9c10cfc0b
@ -37,29 +37,32 @@ class Printer {
|
||||
|
||||
// Turn left or right
|
||||
if (x % 2 == (inverse ? 1 : 0)) {
|
||||
Turtle.turnRight();
|
||||
Turtle.turnLeft();
|
||||
Turtle.forward();
|
||||
Turtle.turnRight();
|
||||
Turtle.turnLeft();
|
||||
} else {
|
||||
Turtle.turnLeft();
|
||||
Turtle.turnRight();
|
||||
Turtle.forward();
|
||||
Turtle.turnLeft();
|
||||
Turtle.turnRight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
Turtle.up(); // We place the block below us so move up.
|
||||
|
||||
for (i in 0...structure.height()) {
|
||||
var layer = structure.getLayer(i);
|
||||
var inverse = i % 2 == 0;
|
||||
|
||||
printLayer(layer, inverse);
|
||||
|
||||
// Don't go up on the last layer
|
||||
if (i != structure.height() - 1) {
|
||||
Turtle.up();
|
||||
// Don't go up or turn around on the last layer
|
||||
if (i == structure.height() - 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Turtle.up();
|
||||
Turtle.turnLeft();
|
||||
Turtle.turnLeft();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user