Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » edge bounce
- wisco11
-
15 posts
edge bounce
hey guys, I'm making a bouncing square project but I need to know, what would it look like if the
if on edge, bouncewas a custom block
define if on edge, bounce
- awesome-llama
-
1000+ posts
edge bounce
The blocks are open source, you can see the code here: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_motion.js#L186-L240
- P0rpleStar
-
100+ posts
edge bounce
If I'm not mistaken, it should be the following script:
if <<(x position) > [240]> or <(x position) < [-240]>> thenThe numbers the script checks can be altered to what you'd like to be the boundaries of your field, or you can do what I did and just flat out use sprites to act as your walls instead of coordinates.
point in direction ((direction) * (-1))
end
if <<(y position) > [180]> or <(y position) < [-180]>> then
point in direction ((180) - (direction))
end
Last edited by P0rpleStar (Feb. 19, 2025 15:33:26)
- zeiraph
-
100+ posts
edge bounce
yes he did wait did you mean y position for both in the second if?
- P0rpleStar
-
100+ posts
edge bounce
Oh- Yeah I did. Sorry, lol. wait did you mean y position for both in the second if?
- wisco11
-
15 posts
edge bounce
wait also I wanted it to bounce of a certain color, so I don't think this is what I need. but still, thanks!

- Discussion Forums
- » Help with Scripts
-
» edge bounce