--CHA0S-- --CHA0S-- loading

ramenecho wrote:

TheRealRldFan wrote:

I just need more examples of Collision with:
define Block name
Ok so if you want something to collide with an object preventing it from moving past it, im assuming you want it to collide with a form of immovable wall, just make it so every time the sprite moves it checks to see if it is touching the object, and if so then you move with the opposite, example:
change x by (x velocity)
change y by (y velocity)
if <touching [wall sprite v] ?> then
change x by ((-1) * (x velocity))
change y by ((-1) * (y velocity))
end
I hope this helps!
You could break it down a bit further to detect if it was an x collision or a y collision like this
change x by (x velocity)
change y by (y velocity)
if <touching [wall sprite v] ?> then
change x by ((-1) * (x velocity))
if <touching [wall sprite v] ?> then
change x by (x velocity)
change y by ((-1) * (y velocity))
if <touching [wall sprite v] ?> then
change x by ((-1) * (x velocity))
else
stop [this script v]
else
stop [this script v]
end