Stretch Effect and Bounce

Cremax

Since I sent bounce.zip to Adok for Hugi #13 for the bonus archive (I dunno why, but what the hell ;) I guess I should post some words about it. Because of the effect you can't read what I wrote. I take no responsibility for any damage or/and if anyone except that bitch gets offended. Don't tell me I didn't warn you. ;)

The bouncing effect was simply made by adding random values to the co-ordinates where the picture is to be displayed on the screen.

The stretch effect is just a simple blur in the x-axis! For each step, you subtract the number of steps from each pixel of the image. This is what I mean:

 c += (unsigned char) *(img+ytab[y]+x+i-count);

Then you just plot the pixel with the 'c' color divided by the number of steps.

Here is the source of the two routines:

 void stretch(unsigned char *img, int posx, int posy, int s, unsigned
 char *mem)
 {
   long c=0;
   int count=s;
   int totpix=count+1;  // add one in case of zero

   for(int y=0;y<200;y++)
   for(int x=0;x<320;x++)
   {
     for(int i=0;i<totpix;i++)
       c += (unsigned char) *(img+ytab[y]+x+i-count);

     mem[ytab[y+posy]+x+posx] = (c/totpix);

     c=0;
   }
 }

 void bounce( unsigned char *whereto, unsigned char *buffer)
 {
     x=rand()*15/64000;
     y=ytab[(rand()*15/64000)];
     memcpy(whereto, buffer+x+y, 320*200);
 }

Happy coding...
c r e m a x /