Stay on path in a maze

Hello, all.

I have several students who want to create a game that includes a maze. They are interested in having their sprites bounce off the walls of the maze sprite (a background image in all cases). isTouching won’t check for a color; it only finds overlap between sprites and groups. I’m not sure how they can code this into their games without having to make every wall of the maze into a sprite? Any ideas out there? Maybe I’m missing something simple.

Thanks,
Susan

I’ve had a student make a maze and yes, we made a bunch of sprites that overlapped to make a maze. It wasn’t a great solution but it worked. Hopefully someone else will chime in with a better solution.

At least it’s workable. Do you still have a link to the game so we could take a look? That would be helpful.

Also, I don’t know a ton about groups. Does anyone know if this would this be an instance where a group might work? Or does it treat the group like 1 large sprite and the collision zone would apply to them all?

Hi Susan,
Each sprite in a group maintains its own collider “zone”. Here’s a quick example:

1 Like

Awesome! Thank you for info about groups and the example, Mike.

Actually, the only way to make a full maze is to make every block a single sprite. If you want some to make the player/user bounce, make a group of those blocks then do:
if(Player.isTouching(BounceGroup)){Player.bounceOff(BounceGroup)}. Also make sure to set the bounciness of that group to greater than one, else it will look like it just collided.