Discuss Scratch

triton999
Scratcher
5 posts

How to make sprites bounce

I am making a project that requires sprites to bounce off each other but I can't figure out how. It uses velocity vectors. Link to the project Bouncing Sprunkis
player_88
Scratcher
10 posts

How to make sprites bounce

when your working with velocities, you can multiply them both by -1 to make the sprite bounce.
set [x velocity v] to ((x velocity) * (-1))
set [y velocity v] to ((y velocity) * (-1))
usually you would check for bouncing right after moving the sprite on that axis.
forever
change x by (x velocity)
if <collision?> then
set [x velocity v] to ((x velocity) * (-1))
end
change y by (y velocity)
if <collision?> then
set [y velocity v] to ((y velocity) * (-1))
end
end
if you want to make it bounce less, then you can multiply by something between 0 and -1, like -0.5
hope that helped.

Powered by DjangoBB