added default values for chessboard()
This commit is contained in:
parent
fe3530788a
commit
97553d7da4
1 changed files with 22 additions and 20 deletions
|
@ -2,29 +2,31 @@
|
|||
* Creates a tile pattern of given block types and size
|
||||
*
|
||||
* Paramters:
|
||||
* whiteBlock - blockId used for the traditional white portion of the chessboard
|
||||
* blackBlock - blockId used for the traditional black portion of the chessboard
|
||||
* width - width of the chessboard
|
||||
* height - height of the chessboard
|
||||
* whiteBlock - blockId used for the traditional white portion of the chessboard
|
||||
* blackBlock - blockId used for the traditional black portion of the chessboard
|
||||
* width - width of the chessboard
|
||||
* height - height of the chessboard
|
||||
*/
|
||||
load(__folder + "drone.js");
|
||||
|
||||
Drone.extend("chessboard", function(whiteBlock, blackBlock, width, depth) {
|
||||
this.chkpt('chessboard-start');
|
||||
this.chkpt('chessboard-start');
|
||||
width = width || 8;
|
||||
depth = depth || width;
|
||||
blackBlock = blackBlock || blocks.wool.black;
|
||||
whiteBlock = whiteBlock || blocks.wool.white;
|
||||
|
||||
var dep = depth || width;
|
||||
for(var i = 0; i < width; ++i) {
|
||||
for(var j = 0; j < depth; ++j) {
|
||||
var block = blackBlock;
|
||||
if((i+j)%2 == 1) {
|
||||
block = whiteBlock;
|
||||
}
|
||||
this.box(block);
|
||||
this.right();
|
||||
}
|
||||
this.move('chessboard-start').fwd(i+1);
|
||||
}
|
||||
|
||||
for(var i = 0; i < width; ++i) {
|
||||
for(var j = 0; j < dep; ++j) {
|
||||
var block = blackBlock;
|
||||
if((i+j)%2 == 1) {
|
||||
block = whiteBlock;
|
||||
}
|
||||
this.box(block);
|
||||
this.right();
|
||||
}
|
||||
this.move('chessboard-start').fwd(i+1);
|
||||
}
|
||||
|
||||
return this.move('chessboard-start');
|
||||
return this.move('chessboard-start');
|
||||
});
|
||||
|
|
Reference in a new issue