Is it possible to make a sprite get blocked by a block? as in lets say i draw a yellow square, and i want to script it so that the sprite cant move anywhere into the yellow square, I've tried and tried but it just won't work, either the sprite will just move in to and then float up or down. Sort of like mario where you can't go inside the terrain and instead get blocked. Thank you.
Offline
It seems like this would require sensing; this project should be able to explain how to do this (under the sensing tab).
Offline
Yes, but there isn't a single block like "if touching sprite[] bounce". As laptop97 said above, it requires sensing and building your own collision script. Depending on what exactly you want to accomplish, such scripts can vary immensely. Platform scripts tend to be complex than top-down collision scripts, and scripts with velocity tend to be more complex than those without.
Anyway, I can't really answer until I know more details, sorry. But the basic concept is:
Loop:
Move
Check if you're touching the sprite
If you are, move back.
End Loop
Offline
sounds like a good case for sensing to me too but if you want to do your own edge-type bouncing off of an object, here are the 2 formulas for figuring the bounce (depending on whether you hit the sides or top/bottom of an object...
Pong type bounce
this is probably only a partial answer to your question but one of these formulas often confuses us Scratchers so... bam! there it is!!
Offline