I am making a puzzle game, and to complete each puzzle, you need to shoot an energy bolt, and have it deflect off of certain blocks. Does anyone know the formula or script to make something have generally the same function as the 'if on edge, bounce' block? Any help is greatly appreciated.
Offline
The behaviour of on-edge bounce is simply:
<point in direction <(direction) * [-1]> >Use either the current x/y position compared against your targets x/y position or a touching color/target block to detect when to switch directions.
Offline
plemon11 wrote:
The behaviour of on-edge bounce is simply:
point in direction <(direction) * (-1)>Use either the current x/y position compared against your targets x/y position or a touching color/target block to detect when to switch directions.
Hopefully, this has pointed you in the right direction (pun totally intended.)
Phill
Fixed. Anyway, that is not how you make a bounce with vertical and horizontal surfaces. This is how you make a bounce with more types of surface:
if <touching [left or right side of block v]?> point in direction ((direction) * (-1)) end if <touching [top or bottom side of block v]?> point in direction (((direction) * (-1)) + (180)) endI hope that this helps!
Last edited by ErnieParke (2012-08-25 17:54:24)
Offline
ErnieParke wrote:
Fixed. Anyway, that is not how you make a bounce with every type of surface. This is how you make a bounce with every type of surface:
if <touching [left or right side of block v]?> point in direction ((direction) * (-1)) end if <touching [top or bottom side of block v]?> point in direction (((direction) * (-1)) + (180)) endI hope that this helps!
ErnieParke is correct. A slight change that I'd make to the "top or bottom side" would be to make it "180-direction" instead of "-1*direction + 180", but that's pretty much just personal preference. His script works fine
Edit: if your walls that you're bouncing sprites off of aren't vertical and/or horizontal, it will get more complex. It's still possible, but you have to know either the slope or the angle of both the wall and the "bouncing sprite"
Last edited by MoreGamesNow (2012-08-25 17:41:00)
Offline
If it's any use, you can check out an old Pinball project of mine which uses "deflection formulas" (just different operations depending on slope) to calculate bounce angles. Here's the project:
http://scratch.mit.edu/projects/amcerbu/1004827
EDIT: 600th post!
Last edited by amcerbu (2012-08-26 22:15:49)
Offline
thank you guys so much this will definitely help!
Offline