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)

17th Sep 2018, 11:32 AM
Arthur P
Arthur P - avatar
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(); }
17th Sep 2018, 11:54 AM
jay
jay - avatar
0
Guys, I'm weak at JS, pls give me the answer.
17th Sep 2018, 12:47 PM
Arthur P
Arthur P - avatar