0
Move square to finish with JS loops and function
Hi friends! The task is to move the orange square to finish using loops or functions. Help pls. https://code.sololearn.com/WUh3GJ7BQ693/#html I planned just to write each step, but it would too much of them)
2 Respostas
+ 4
One way to accomplish this would be to write a function to check if the next move results in a wall collision. If it does, change the direction for the next move.
The above would run in a loop until the current cell is the finish cell.
I.e (pseudocode)
while(!success)
{
if(nextMoveCollision() )
ChangeDirection();
else
Move();
}
0
Guys, I'm weak at JS, pls give me the answer.