help with collisions

id: 749524

category: Help with Scripts

posts: 2

I am trying to make a game where the animal will move around the cage randomly but it keeps going through the cage walls can anyone help me fix this
just do something like this. Make sure to set the custom blocks to run without screen refresh.
forever
change x by (xSpeed)
extract from wall x
change y by (ySpeed)
extract from wall y
end

define extract from wall x
repeat until <not <touching [wall] ?>>
if <<(xSpeed) > [0]>> then
change x by (-1)
else
change x by (1)
end
end

define extract from wall y
repeat until <not <touching [wall] ?>>
if <<(ySpeed) > [0]>> then
change y by (-1)
else
change y by (1)
end
end