Pages: 1
Topic closed
I've seen a lot of people ask for this. It's information in high demand. It's been suggested as a new scratch block too. But for now, this is the script to use if you want to get one sprite bounce off another:
[blocks]
<when green flag clicked>
<forever if><touching[ something to bounce off ]>
<turn cw( 180 )degrees>
<end>
[/blocks]
This works if you have a motion block in another script. If you don't you can add motion into the above script like this:
[blocks]
<when green flag clicked>
<forever>
<if><touching[ something to bounce off ]>
<turn cw( 180 )degrees>
<end>
<if><key[ up arrow ]pressed?>
<change y by( 10 )>
<end>
<if><key[down arrow ]pressed?>
<change y by(-10)>
<end>
<if><key[ left arrow ]pressed?>
<change x by(-10)>
<end>
<if><key[right arrow ]pressed?>
<change x by(-10)>
<end>
<end>
[/blocks]
This creates a bouncing sprite that can be moved with the arrow keys!
Hope you found what your looking for!
Scratch On!
Offline
Nice one! Maybe make this into a project so more people can see it in action
Just a little tip, you might want to add a 'wait until not touching sprite' script, because if the sprite your bouncing off is big, it will just keep changing direction.
Last edited by Mozaz (2009-07-02 12:12:46)
Offline
Topic closed
Pages: 1