I am attempting to create a rebound/bouncing script, where an object would bounce off a wall. My attempt is not working, and due to being a noob I have not yet mastered the Scratchblocks code, thus, I can not show you my not-working script. Any help?
Offline
The exact code depends on what exactly you're doing. Do you want accurate redirection of velocity, are the walls all parallel and perpendicular, and are you moving via acceleration or constant velocity?
when gf clicked forever change x by (x-vel) if<touching [wall v]?> set [x-vel v] to ((-1)*(x-vel)) change x by (x-vel) end change y by (y-vel) if<touching [wall v]?> set [y-vel v] to ((-1)*(y-vel)) change y by (y-vel) end
Last edited by MoreGamesNow (2012-06-26 15:36:14)
Offline
http://scratch.mit.edu/projects/fg123_tests/2637559
Here's a simple way to make the sprite bounce off a wall.
Offline