Every time I get to the next screen my hero run to the edge of the screen, how to solve it?
while (true) {
var flag = hero.findFlag();
if(flag) {
hero.moveXY(flag.pos.x, flag.pos.y);
hero.pickUpFlag(flag);
}
var enemy = hero.findNearestEnemy();
if(enemy){
hero.attack(enemy);
}
}
I had the same exact problem and the solution is very silly. When you place your flag at the edge of the screen you have to make sure the entire x, y is on the current screen (use the shadow circle at the flags base). If you place the flag over the edge it places a flag on the very edge of the next screen and your hero will walk across the entire map before breaking the moveXY.
I hope I explained that well. Good luck!
1 Like