diff options
| author | Simon <simon@hardwired.org.uk> | 2011-03-30 17:57:49 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-03-30 17:57:49 (GMT) |
| commit | b7a004986f70986aa9cd314d754deddff6b031f0 (patch) | |
| tree | 8f9329a74cfd1d2718de4e4a8bef62d7313d96ea /src/elements | |
| parent | 3863a7587734be5a010327d869838daf5790d84a (diff) | |
| download | powder-b7a004986f70986aa9cd314d754deddff6b031f0.zip powder-b7a004986f70986aa9cd314d754deddff6b031f0.tar.gz | |
A cracker commit with some nice comments
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/acid.c | 2 | ||||
| -rw-r--r-- | src/elements/aray.c | 16 | ||||
| -rw-r--r-- | src/elements/bomb.c | 2 | ||||
| -rw-r--r-- | src/elements/ice.c | 2 | ||||
| -rw-r--r-- | src/elements/pcln.c | 4 | ||||
| -rw-r--r-- | src/elements/pipe.c | 6 | ||||
| -rw-r--r-- | src/elements/prti.c | 11 | ||||
| -rw-r--r-- | src/elements/prto.c | 19 | ||||
| -rw-r--r-- | src/elements/qrtz.c | 1 | ||||
| -rw-r--r-- | src/elements/swch.c | 2 |
10 files changed, 44 insertions, 21 deletions
diff --git a/src/elements/acid.c b/src/elements/acid.c index 3d9f7b0..875f148 100644 --- a/src/elements/acid.c +++ b/src/elements/acid.c @@ -20,7 +20,7 @@ int update_ACID(UPDATE_FUNC_ARGS) { } else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) { - if (parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) + if (parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid { parts[i].life--; kill_part(r>>8); diff --git a/src/elements/aray.c b/src/elements/aray.c index f323444..ac51f66 100644 --- a/src/elements/aray.c +++ b/src/elements/aray.c @@ -23,27 +23,28 @@ int update_ARAY(UPDATE_FUNC_ARGS) { if (!r) { int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); if (nr!=-1) { - if (destroy) { + if (destroy) {//if it came from PSCN parts[nr].tmp = 2; parts[nr].life = 2; } else parts[nr].ctype = colored; } } else if (!destroy) { - if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==0) { + if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==0) {//if it hits another BRAY that isn't red if (nyy!=0 || nxx!=0) { - parts[r>>8].life = 1020; + parts[r>>8].life = 1020;//makes it last a while parts[r>>8].tmp = 1; - if (!parts[r>>8].ctype) + if (!parts[r>>8].ctype)//and colors it if it isn't already parts[r>>8].ctype = colored; } - docontinue = 0; - } else if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==1) { + docontinue = 0;//then stop it + } else if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==1) {//if it hits one that already was a long life, reset it parts[r>>8].life = 1020; //docontinue = 1; } - else if ((r&0xFF)==PT_FILT) { + else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT colored = parts[r>>8].ctype; + //this if prevents BRAY from stopping on certain materials } else if ((r&0xFF)!=PT_INWR && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { if (nyy!=0 || nxx!=0) { create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); @@ -58,6 +59,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) { if ((r&0xFF)==PT_BRAY) { parts[r>>8].life = 1; docontinue = 1; + //this if prevents red BRAY from stopping on certain materials } else if ((r&0xFF)==PT_INWR || (r&0xFF)==PT_ARAY || (r&0xFF)==PT_WIFI || (r&0xFF)==PT_FILT || ((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { docontinue = 1; } else { diff --git a/src/elements/bomb.c b/src/elements/bomb.c index 59e05f8..8115a88 100644 --- a/src/elements/bomb.c +++ b/src/elements/bomb.c @@ -44,7 +44,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { for (nxi=-rad; nxi<=rad; nxi++) if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) { - delete_part(x+nxi, y+nxj); + delete_part(x+nxi, y+nxj);//it SHOULD kill anything but the exceptions above, doesn't seem to always work pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); if (nb!=-1) { diff --git a/src/elements/ice.c b/src/elements/ice.c index 5b792ce..96bb22b 100644 --- a/src/elements/ice.c +++ b/src/elements/ice.c @@ -2,7 +2,7 @@ int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well int r, rx, ry; - if (parts[i].ctype==PT_FRZW) + if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW { parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); } diff --git a/src/elements/pcln.c b/src/elements/pcln.c index 00e5db0..e1c688e 100644 --- a/src/elements/pcln.c +++ b/src/elements/pcln.c @@ -40,7 +40,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) { (pmap[y+ry][x+rx]&0xFF)!=0xFF) parts[i].ctype = pmap[y+ry][x+rx]&0xFF; if (parts[i].ctype && parts[i].life==10) { - if (parts[i].ctype==PT_PHOT) { + if (parts[i].ctype==PT_PHOT) {//create photons a different way for (rx=-1; rx<2; rx++) { for (ry=-1; ry<2; ry++) { int r = create_part(-1, x+rx, y+ry, parts[i].ctype); @@ -51,7 +51,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) { } } } - else if (ptypes[parts[i].ctype].properties&PROP_LIFE) { + else if (ptypes[parts[i].ctype].properties&PROP_LIFE) {//create life a different way for (rx=-1; rx<2; rx++) { for (ry=-1; ry<2; ry++) { create_part(-1, x+rx, y+ry, parts[i].ctype); diff --git a/src/elements/pipe.c b/src/elements/pipe.c index 7d709aa..849d2ea 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -4,7 +4,7 @@ int update_PIPE(UPDATE_FUNC_ARGS) { int r, rx, ry, np, trade, q, ctype; if (!parts[i].ctype && parts[i].life<=10) { - if (parts[i].temp<272.15) + if (parts[i].temp<272.15)//manual pipe colors { if (parts[i].temp>173.25&&parts[i].temp<273.15) { @@ -32,13 +32,13 @@ int update_PIPE(UPDATE_FUNC_ARGS) { if ((r>>8)>=NPART ) continue; if (!r) - create_part(-1,x+rx,y+ry,PT_BRCK); + create_part(-1,x+rx,y+ry,PT_BRCK);//BRCK border, people didn't like DMND } if (parts[i].life==1) parts[i].ctype = 1; } } - if (parts[i].ctype==1) + if (parts[i].ctype==1)//waiting for empty space { for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) diff --git a/src/elements/prti.c b/src/elements/prti.c index fa87562..2b08aae 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -1,5 +1,14 @@ #include <element.h> - +/*these are the count vaules of where the particle gets stored, depending on where it came from + 1 4 6 + 2 . 7 + 3 5 8 + PRTO counts backwards, so that it will come out at the opposite place of where it came in + 8 5 3 + 7 . 2 + 6 4 1 + PRTO does +/-1 to the count, so it doesn't jam as easily +*/ int update_PRTI(UPDATE_FUNC_ARGS) { int r, nnx, rx, ry, fe = 0; int count =0; diff --git a/src/elements/prto.c b/src/elements/prto.c index 9bec996..adf82a7 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -1,5 +1,14 @@ #include <element.h> - +/*these are the count vaules of where the particle gets stored, depending on where it came from + 1 4 6 + 2 . 7 + 3 5 8 + PRTO counts backwards, so that it will come out at the opposite place of where it came in + 8 5 3 + 7 . 2 + 6 4 1 + PRTO does +/-1 to the count, so it doesn't jam as easily +*/ int update_PRTO(UPDATE_FUNC_ARGS) { int r, nnx, rx, ry, np, fe = 0; int count = 0; @@ -20,12 +29,12 @@ int update_PRTO(UPDATE_FUNC_ARGS) { { for ( nnx =0 ; nnx<80; nnx++) { - int randomness = count + rand()%3-1; + int randomness = count + rand()%3-1;//add -1,0,or 1 to count if (randomness<1) randomness=1; - if (randomness>9) - randomness=9; - if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better + if (randomness>8) + randomness=8; + if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better, spark creation { create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]); create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]); diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c index 431c46e..4d3662f 100644 --- a/src/elements/qrtz.c +++ b/src/elements/qrtz.c @@ -12,6 +12,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { part_change_type(i,x,y,PT_PQRT); } } + //new QRTZ growth for (rx=-2; rx<3 && parts[i].ctype!=-1; rx++) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) diff --git a/src/elements/swch.c b/src/elements/swch.c index 043bf23..0bd5e6d 100644 --- a/src/elements/swch.c +++ b/src/elements/swch.c @@ -25,10 +25,12 @@ int update_SWCH(UPDATE_FUNC_ARGS) { } } } + //turn off SWCH from two red BRAYS if (parts[i].life==10 && (!(pmap[y-1][x-1]&0xFF) && ((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) && !(pmap[y-1][x+1]&0xFF) && ((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2))) { parts[i].life = 9; } + //turn on SWCH from two red BRAYS else if (parts[i].life<=5 && (!(pmap[y-1][x-1]&0xFF) && (((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) || ((pmap[y+1][x]&0xFF)==PT_BRAY&&parts[pmap[y+1][x]>>8].tmp==2)) && !(pmap[y-1][x+1]&0xFF) && (((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2) || ((pmap[y][x-1]&0xFF)==PT_BRAY&&parts[pmap[y][x-1]>>8].tmp==2)))) { parts[i].life = 14; |
