This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-06 05:24:20

spengilley
New Scratcher
Registered: 2010-07-06
Posts: 1

Auto-navigate a maze

Hi all,

I have written some code which essentially changes direction when touching the wall and moves on but I haven't been able to make the sprite automatically enter 'open doors' or 'gaps' in the maze wall. It will only change direction if it hits the maze wall itself. I will post a screenshot of my code

http://content.screencast.com/users/SPengilley/folders/Default/media/36e9c1e1-a22e-47f9-8d6f-8a71469d267f/maze-automate.bmp" width="496" height="542" border="0"

Offline

 

#2 2010-07-06 23:24:55

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Auto-navigate a maze

You could solve many of the problems by making "checks" that test all four sides of your sprite. You can either make one for each side, or a single one with different colors on each side, but the premise is the same.

Have these sensors check if a side of the sprite is facing an open space in the maze with an "If touching color..." block. Then have it evaluate if that open space would lead in the direction the sprite needs to take to reach its goal.

Does that make sense?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-07-07 19:44:19

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Auto-navigate a maze

I like Harakou's idea better but you could also just use a hidden sprite that sits in the middle of a door or opening. The player sprite could wait till it is close enough, then if direction = whatever set direction to whatever  smile


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer