(Best viewed in a browser with JavaScript enabled. You can click the play/run-buttons to run the JavaScript in the embedded editors. It should behave mostly like running the same code in the JavaScript console. (Hitting F12 or something and finding the console might also be useful if you wanna look around and inspect stuff more or something.))
Previously we made the cat move.
Very playable.
You’ve won the game if every goal has a box on it. So if there are no goal squares left with either nothing on them or player on them:
We’ll test it with a won level:
Seems fine. Let’s fix the commands so they take winning into account, and switch to very winnable level for testing:
Seems fine.
Also let’s implement undo. Undoing a move is kind of like moving in the opposite direction:
We undo by:
moveList
.moveList
.We can restart a level by undoing a lot:
Okay okay. It’s probably a game now...