I am having this problem where I can’t beat the level because it keeps saying “don’t hand-place the rectangles”. But I am not hand-placing them(I think), I have them encoded in a formula. I have tried many different approaches to this, could somebody help me by telling me what I am doing wrong, or explaining exactly what “hand-placing” is?
Here’s my code if you need it:
// hero.addRect(x, y, width, height) places a rectangle to collect coins
// hero.removeRectAt(x, y) removes a previously added rectangle at the point.
// hero.navGrid is (basically) a 2-dimensional array containing "Coin" or "Wall"
var map = hero.navGrid;
function addRects(row) {
var y = row;
var pass = 0;
for (var col in map[row]) {
var pos = map[col][row];
if (pos=="Coin"&&pass===0) {
var x = col;
var w = 1;
pass = 1;
} else if (pos=="Coin") {
w++;
} else if (pos=="Wall"&&pass>0) {
hero.addRect(x,y,w,1);
pass = 0;
}
}
if (w==20) {
hero.addRect(x,y,20,1);
}
}
hero.wait(1);
for (var i = 0; i < 21; i++) {
addRects(i);
}
Nevermind, I figured it out.