Discuss Scratch

wisco11
Scratcher
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, bounce
was a custom block
define if on edge, bounce
awesome-llama
Scratcher
1000+ posts

edge bounce

wisco11
Scratcher
15 posts

edge bounce

i meant in block code
P0rpleStar
Scratcher
100+ posts

edge bounce

If I'm not mistaken, it should be the following script:
if <<(x position) > [240]> or <(x position) < [-240]>> then
point in direction ((direction) * (-1))
end
if <<(y position) > [180]> or <(y position) < [-180]>> then
point in direction ((180) - (direction))
end
The 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.

Last edited by P0rpleStar (Feb. 19, 2025 15:33:26)

wisco11
Scratcher
15 posts

edge bounce

thanks
wisco11
Scratcher
15 posts

edge bounce

wait did you mean y position for both in the second if?
wisco11
Scratcher
15 posts

edge bounce

wait???
zeiraph
Scratcher
100+ posts

edge bounce

wisco11 wrote:

wait did you mean y position for both in the second if?
yes he did
P0rpleStar
Scratcher
100+ posts

edge bounce

wisco11 wrote:

wait did you mean y position for both in the second if?
Oh- Yeah I did. Sorry, lol.
wisco11
Scratcher
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!

Powered by DjangoBB