Discuss Scratch

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:
when [ left arrow] key pressed
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)
Then, lets say your walls are pinkish. Add these scripts to the according
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!
cramboodrumbo
Scratcher
1 post

How to stop sprites from moving through walls in maze games.

Powered by DjangoBB