Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to stop sprites from moving through walls in maze games.
- rgp007
- Scratcher
13 posts
How to stop sprites from moving through walls in maze games.
This will help you in a maze game.(As it is pesky when sprites jump the walls.)
Step one:
Step one:
when [ left arrow] key pressedThen, lets say your walls are pinkish. Add these scripts to the according
change x by (5)
when [ right arrow] key pressed
change x by (-5)
when [ up arrow] key pressed
change y by (5)
when [ down arrow] key pressed
change y by (-5)
if <touching color [#ff0088] ?> then
change x by (-5) for first or 5 for second
if <touching color [#ff0088] ?> then
change y by (-5) for first or 5 for second
end
end
- Carterboy11
- Scratcher
10 posts
How to stop sprites from moving through walls in maze games.
when [Left Arrow v] key pressed
change x by (-5)
if <touching color [#ff0088] ?> then
change x by (5)
end
when [Right Arrow v] key pressed
change x by (5)
if <touching color [#ff0088] ?> then
change x by (-5)
end
when [Up Arrow v] key pressed
change y by (5)
if <touching color [#ff0088] ?> then
change y by (-5)
end
when [Down Arrow v] key pressed
change y by (-5)
if <touching color [#ff0088] ?> then
change y by (5)
end
This Script Should Work for what you're trying to do!
- Discussion Forums
- » Help with Scripts
- » How to stop sprites from moving through walls in maze games.