Discuss Scratch

Puplove22
Scratcher
2 posts

Ball bouncing project

I want to make a project where when you click the green flag, the ball will glide in a random direction to one of the walls randomly, and then bounce off the wall, repeating the process. However, I do not know how to make it glide to the wall, it only goes to some random location. Also, I wanted to make it so that every time it hits the wall, the size increases. However, after it passes size 180, the path behind it disappears. Does anybody know how to fix this? Here is the game so far: https://scratch.mit.edu/projects/1023756541

Last edited by Puplove22 (May 22, 2024 23:36:24)

BluesyBear3
Scratcher
5 posts

Ball bouncing project

You have the ball set to glide of a random location on the screen, not necessarily to a wall. Perhaps make it point to a random direction and keep moving until it touches a wall. The reason why it stops leaving a path after a certain amount of time is due to scratch's clone limit. Instead, you could use the pen tool to create stamps.
FroYo666
Scratcher
27 posts

Ball bouncing project

whenclickedbroadcastStartwhenIreceiveStartpointindirectionpickrandom-179to180vrepeatuntiltouchingedge?move2stepswhenclickedforeverifonedge,bouncewhenIreceiveStartiftouchingEdge?thenbroadcastStartend

That should work

Last edited by FroYo666 (May 23, 2024 01:16:16)

FroYo666
Scratcher
27 posts

Ball bouncing project

@BluesyBear3 is right about using pen instead of clone, if you need help with stamping, let me know. Also, if my code doesnt work, i can mess around with it and get you a working code.

Last edited by FroYo666 (May 23, 2024 01:20:26)

Puplove22
Scratcher
2 posts

Ball bouncing project

Thank you so much! Both of you have helped move this project forward! I will make sure to give you guys credit.

Powered by DjangoBB