move_bounce_rectangle

Downloadmove_bounce_rectangle(x1,y1,x2,y2)   If the bounding box of the calling instance crosses the boundary of the given rectangle, bounce the instance in the opposite direction.
/*
**  Usage:
**      move_bounce_rectangle(x1,y1,x2,y2)
**
**  Arguments:
**      x1,y1       upper left corner of bounding rectangle
**      x2,y2       lower right corner of bounding rectangle
**
**  Returns:
**      nothing
**
**  GMLscripts.com
*/

{
    if (bbox_top < argument1)     { y = yprevious; vspeed *= -1; }
    if (bbox_left < argument0)    { x = xprevious; hspeed *= -1; }
    if (bbox_right >= argument2{ x = xprevious; hspeed *= -1; }
    if (bbox_bottom >= argument3) { y = yprevious; vspeed *= -1; }
}

Click if you've used this script[Please Login]
Projects: 6


comments powered by Disqus