0

I'm having trouble getting a mouse to bounce around aimlessly inside of a maze. I created a maze sprite, and I have the mouse constantly moving in the pointed direction at 3 steps. However, while touching the maze sprite, I have him moving -3 steps to ensure he doesn't cross the boundary while also rotating at 1 degree. This works for a while, but eventually he just gets stuck on the maze boundary and rotates in circles forever! I've tried changing the rotating degrees and that didn't work. Also, if I change the sprite to a circle, this solves the problem of the sprite getting stuck on the maze border, but no matter what, the sprite will still get stuck in some random short bouncing pattern. Here is an image below. I appreciate your help! http://imgur.com/NOPzZwE

  • I see all the angles of the maze are right. why not turning the the mouse 90°? also are you sure you want it to move first then turn? – Kareem Jun 3 '16 at 9:54
  • Thank you Kareem! I finally solved it and I'll include what I did below. You are correct that the 90 degrees was the correct solution. In order to make that work, I had to tweek quite a few other things (including have the reverse steps be greater in magnitude than his forward steps, to ensure he doesn't get caught on the wall). – crazyflier Jun 3 '16 at 18:41
0

I was able to solve my problem with the following code. I also had to develop a layer called nodes, for the points on the maze in which the mouse may need to turn without bumping into a wall. If I didn't had this node layer, then the mouse would never enter certain parts of the maze. I added variables so that I would easily be able to add multiple mouses and change all the variables at once from the first master mouse.

scratch screenshot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .