X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fattraction.c;h=8e25d244f1d11aa3544de2c9a4cb7486be218637;hp=0f0e5e73a8f01ca7287dd16c57152a51c6acef8a;hb=07faf451b99879183ed7e909e43a0e065be1ee7f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439 diff --git a/hacks/attraction.c b/hacks/attraction.c index 0f0e5e73..8e25d244 100644 --- a/hacks/attraction.c +++ b/hacks/attraction.c @@ -729,12 +729,17 @@ attraction_draw (Display *dpy, Window window, void *closure) if(st->cbounce_p) /* with correct bouncing */ { /* so long as it's out of range, keep bouncing */ + /* limit the maximum number to bounce to 4.*/ + int bounce_allowed = 4; - while( (st->balls[i].x >= (st->xlim - st->balls[i].size)) || + while( bounce_allowed && ( + (st->balls[i].x >= (st->xlim - st->balls[i].size)) || (st->balls[i].y >= (st->ylim - st->balls[i].size)) || (st->balls[i].x <= 0) || (st->balls[i].y <= 0) ) + ) { + bounce_allowed--; if (st->balls[i].x >= (st->xlim - st->balls[i].size)) { st->balls[i].x = (2*(st->xlim - st->balls[i].size) - st->balls[i].x);