Guest User

pcnv.c

a guest
Jun 24th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.28 KB | None | 0 0
  1. /*
  2.  * This program is free software; you can redistribute it and/or modify
  3.  * it under the terms of the GNU General Public License as published by
  4.  * the Free Software Foundation; either version 3 of the License, or
  5.  * (at your option) any later version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful,
  8.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  * GNU General Public License for more details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License
  13.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15.  
  16. #include <element.h>
  17.  
  18. int update_PCNV(UPDATE_FUNC_ARGS) {
  19.     int r, rx, ry;
  20.     if (parts[i].life>0 && parts[i].life!=10)
  21.         parts[i].life--;
  22.     for (rx=-2; rx<3; rx++)
  23.         for (ry=-2; ry<3; ry++)
  24.             if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  25.             {
  26.                 r = pmap[y+ry][x+rx];
  27.                 if (!r)
  28.                     continue;
  29.                 if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4)
  30.                 {
  31.                     if (parts[r>>8].ctype==PT_PSCN)
  32.                         parts[i].life = 10;
  33.                     else if (parts[r>>8].ctype==PT_NSCN)
  34.                         parts[i].life = 9;
  35.                 }
  36.                 if ((r&0xFF)==PT_PCNV)
  37.                 {
  38.                     if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
  39.                         parts[i].life = 9;
  40.                     else if (parts[i].life==0&&parts[r>>8].life==10)
  41.                         parts[i].life = 10;
  42.                 }
  43.             }
  44.        
  45.     if(parts[i].life == 10) {  
  46.         if(parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_CONV) {
  47.             for (rx=-1; rx<2; rx++)
  48.                 for (ry=-1; ry<2; ry++)
  49.                     if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
  50.                     {
  51.                         r = photons[y+ry][x+rx];
  52.                         if (!r)
  53.                             r = pmap[y+ry][x+rx];
  54.                         if (!r)
  55.                             continue;
  56.                         if((r&0xFF)!=PT_PCNV && (r&0xFF)!=parts[i].ctype)
  57.                         {
  58.                             if (parts[i].ctype==PT_LIFE) create_part(r>>8, x+rx, y+ry,parts[i].ctype|(parts[i].tmp<<8));
  59.                             else create_part(r>>8, x+rx, y+ry, parts[i].ctype);
  60.                         }
  61.                     }
  62.         }
  63.     }
  64.    
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment