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

#1 2012-02-11 14:50:35

pietestaccount1234
Scratcher
Registered: 2012-01-25
Posts: 10

i need a little help here

Can someone plz explain how to make walls solid in a maze???????

Offline

 

#2 2012-02-11 16:26:48

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: i need a little help here

It's not the solidity of the walls, there is a script for the player to sense the walls. To figure out how to do Wall Sensors, as they are called, go to the Scratch Wiki article about it.

Last edited by Paddle2See (2012-02-11 16:28:02)


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#3 2012-02-11 16:33:27

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: i need a little help here

Besides the wall sensing technique that henley points to above, there are other simpler methods that don't require sensor sprites, but are maybe best suited to simple maze games and such. 

One of my favorites uses a couple of variables to keep track of the last place the sprite was that was not touching a wall.  If it touches a wall after a motion, it just "rewinds" back to the last spot where it was not touching.  You can see a demo of this technique over here.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2012-02-11 16:34:59

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Re: i need a little help here

I''ve put together a project for you so you can see how it's done. click here to go to the project.

Usually, sensor boxes are implemented onto the main character of the game, and the ghost effects of them are set to 100, so that they still function properly, but are hidden.

I hope I helped! (:

Last edited by Zparx (2012-02-11 19:53:33)


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#5 2012-02-11 18:45:28

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: i need a little help here

Paddle2See wrote:

Besides the wall sensing technique that henley points to above, there are other simpler methods that don't require sensor sprites, but are maybe best suited to simple maze games and such. 

One of my favorites uses a couple of variables to keep track of the last place the sprite was that was not touching a wall.  If it touches a wall after a motion, it just "rewinds" back to the last spot where it was not touching.  You can see a demo of this technique over here.

One thing that may or may not be a problem - depending on what you want - is that, when running into a wall on one dimension, it prevents movement on the other one.  A solution is this script:

when gf clicked
forever
if <key [right] pressed?>
change x by (5)
if <touching color [black]?>
change x by (-5)
end
end
if <key [left] pressed?>
change x by (-5)
if <touching color [black]?>
change x by (5)
end
if <key [up] pressed?>
change y by (5)
if <touching color [black]?>
change y by (-5)
end
end
if <key [down] pressed?>
change y by (-5)
if <touching color [black]?>
change y by (5)
end
end
end
end

Last edited by MoreGamesNow (2012-02-13 16:40:39)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2012-02-12 13:32:19

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: i need a little help here

MoreGamesNow wrote:

Paddle2See wrote:

Besides the wall sensing technique that henley points to above, there are other simpler methods that don't require sensor sprites, but are maybe best suited to simple maze games and such. 

One of my favorites uses a couple of variables to keep track of the last place the sprite was that was not touching a wall.  If it touches a wall after a motion, it just "rewinds" back to the last spot where it was not touching.  You can see a demo of this technique over here.

One thing that may or may not be a problem - depending on what you want is that, when running into a wall on one dimension, it prevents movement on the other one.  A solution is this script:

when gf clicked
forever
if <key [right] pressed?>
change x by (5)
if <touching color [black]?>
change x by (-5)
end
end
if <key [left] pressed?>
change x by (-5)
if <touching color [black]?>
change x by (5)
end
if <key [up] pressed?>
change y by (5)
if <touching color [black]?>
change y by (-5)
end
end
if <key [down] pressed?>
change y by (-5)
if <touching color [black]?>
change y by (5)
end
end
end
end

Yes, but what if you begin touching a wall? You could press [left] and you'd get through the wall!

Offline

 

#7 2012-02-12 13:36:03

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: i need a little help here

rdococ wrote:

Yes, but what if you begin touching a wall? You could press [left] and you'd get through the wall!

If you press left, you move left "-5" and then, if you're touching the wall (black, in this case), you counter act this move and end up exactly where you were.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#8 2012-02-13 15:51:10

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: i need a little help here

Do this if you want it to go back to the start:

 
if <touching color [#F8567D]?> // You can put a different color in, of course. 
go to x: (123) y: (456) // of course, you could put different X and Y positions in. 
end

Last edited by Mokat (2012-02-13 15:52:49)


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

Board footer