home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 January / pcw-0195.iso / polyray / dat / animate / thresh / blbmv.inc next >
Encoding:
Text File  |  1994-12-31  |  3.5 KB  |  126 lines

  1. if (frame == start_frame) {
  2.    // Set the initial position and velocity of each blob component
  3.    static define px0  0
  4.    static define py0  0
  5.    static define vx0  0.25
  6.    static define vy0 -0.15
  7.  
  8.    static define px1  0
  9.    static define py1  0
  10.    static define vx1 -0.05
  11.    static define vy1  0.3
  12.  
  13.    static define px2  0
  14.    static define py2  0
  15.    static define vx2  0.25
  16.    static define vy2  0.15
  17.  
  18.    static define px3  0
  19.    static define py3  0
  20.    static define vx3  0.2
  21.    static define vy3 -0.15
  22.  
  23.    static define px4  0
  24.    static define py4  0
  25.    static define vx4 -0.1
  26.    static define vy4  0.2
  27.    }
  28. else {
  29.    // Recalculate the positions and velocities of each component
  30.  
  31.    static define px0 px0 + vx0
  32.    if (px0 > bwidth) {
  33.       static define px0 2 * bwidth - px0
  34.       static define vx0 -vx0 + rbounce
  35.       }
  36.    else if (px0 < -bwidth)  {
  37.       static define px0 -2 * bwidth - px0
  38.       static define vx0 -vx0 + rbounce
  39.       }
  40.    static define py0 py0 + vy0
  41.    if (py0 > bheight) {
  42.       static define py0 2 * bheight - py0
  43.       static define vy0 max(min(-vy0 + rbounce, 1), -1)
  44.       }
  45.    else if (py0 < -bheight) {
  46.       static define py0 -2 * bheight - py0
  47.       static define vy0 max(min(-vy0 + rbounce, 1), -1)
  48.       }
  49.  
  50.    static define px1 px1 + vx1
  51.    if (px1 > bwidth) {
  52.       static define px1 2 * bwidth - px1
  53.       static define vx1 -vx1 + rbounce
  54.       }
  55.    else if (px1 < -bwidth)  {
  56.       static define px1 -2 * bwidth - px1
  57.       static define vx1 -vx1 + rbounce
  58.       }
  59.    static define py1 py1 + vy1
  60.    if (py1 > bheight) {
  61.       static define py1 2 * bheight - py1
  62.       static define vy1 max(min(-vy1 + rbounce, 1), -1)
  63.       }
  64.    else if (py1 < -bheight) {
  65.       static define py1 -2 * bheight - py1
  66.       static define vy1 max(min(-vy1 + rbounce, 1), -1)
  67.       }
  68.  
  69.    static define px2 px2 + vx2
  70.    if (px2 > bwidth) {
  71.       static define px2 2 * bwidth - px2
  72.       static define vx2 -vx2 + rbounce
  73.       }
  74.    else if (px2 < -bwidth)  {
  75.       static define px2 -2 * bwidth - px2
  76.       static define vx2 -vx2 + rbounce
  77.       }
  78.    static define py2 py2 + vy2
  79.    if (py2 > bheight) {
  80.       static define py2 2 * bheight - py2
  81.       static define vy2 max(min(-vy2 + rbounce, 1), -1)
  82.       }
  83.    else if (py2 < -bheight) {
  84.       static define py2 -2 * bheight - py2
  85.       static define vy2 max(min(-vy2 + rbounce, 1), -1)
  86.       }
  87.  
  88.    static define px3 px3 + vx3
  89.    if (px3 > bwidth) {
  90.       static define px3 2 * bwidth - px3
  91.       static define vx3 -vx3 + rbounce
  92.       }
  93.    else if (px3 < -bwidth)  {
  94.       static define px3 -2 * bwidth - px3
  95.       static define vx3 -vx3 + rbounce
  96.       }
  97.    static define py3 py3 + vy3
  98.    if (py3 > bheight) {
  99.       static define py3 2 * bheight - py3
  100.       static define vy3 max(min(-vy3 + rbounce, 1), -1)
  101.       }
  102.    else if (py3 < -bheight) {
  103.       static define py3 -2 * bheight - py3
  104.       static define vy3 max(min(-vy3 + rbounce, 1), -1)
  105.       }
  106.  
  107.    static define px4 px4 + vx4
  108.    if (px4 > bwidth) {
  109.       static define px4 2 * bwidth - px4
  110.       static define vx4 -vx4 + rbounce
  111.       }
  112.    else if (px4 < -bwidth)  {
  113.       static define px4 -2 * bwidth - px4
  114.       static define vx4 -vx4 + rbounce
  115.       }
  116.    static define py4 py4 + vy4
  117.    if (py4 > bheight) {
  118.       static define py4 2 * bheight - py4
  119.       static define vy4 max(min(-vy4 + rbounce, 1), -1)
  120.       }
  121.    else if (py4 < -bheight) {
  122.       static define py4 -2 * bheight - py4
  123.       static define vy4 max(min(-vy4 + rbounce, 1), -1)
  124.       }
  125.    }
  126.