Can someone plz explain how to make walls solid in a maze???????
Offline
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)
Offline
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.
Offline
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)
Offline
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)
Offline
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
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.
Offline
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)
Offline