diff options
| author | Simon <simon@hardwired.org.uk> | 2011-03-24 19:41:45 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-03-24 19:41:45 (GMT) |
| commit | 3ab47ae9d76e9e5e0416f81e43de15417354caf5 (patch) | |
| tree | d80fbec366baa970cd565ca5a17decb444036fad /src | |
| parent | fe90c86fa1f1365d07dc6eee83b074d08efec05a (diff) | |
| download | powder-3ab47ae9d76e9e5e0416f81e43de15417354caf5.zip powder-3ab47ae9d76e9e5e0416f81e43de15417354caf5.tar.gz | |
Effects for PRTO and PRTI
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/prti.c | 32 | ||||
| -rw-r--r-- | src/elements/prto.c | 29 | ||||
| -rw-r--r-- | src/graphics.c | 90 | ||||
| -rw-r--r-- | src/powder.c | 42 |
4 files changed, 168 insertions, 25 deletions
diff --git a/src/elements/prti.c b/src/elements/prti.c index 560ba8c..fa87562 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -1,7 +1,7 @@ #include <element.h> int update_PRTI(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry; + int r, nnx, rx, ry, fe = 0; int count =0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; @@ -12,6 +12,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || !r) continue; if ((r&0xFF)==PT_SPRK || ((r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (ptypes[r&0xFF].falldown!= 0 || ptypes[r&0xFF].state == ST_GAS))) @@ -28,5 +30,33 @@ int update_PRTI(UPDATE_FUNC_ARGS) { break; } } + + + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]>1){ + orbd[r] -= 12; + if(orbd[r]<1){ + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } else { + orbl[r] += 2; + orbl[r] = orbl[r]%255; + } + } else { + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/elements/prto.c b/src/elements/prto.c index fbbd5a1..9bec996 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -1,7 +1,7 @@ #include <element.h> int update_PRTO(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, np; + int r, nnx, rx, ry, np, fe = 0; int count = 0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; @@ -12,6 +12,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || r) continue; if (!r) @@ -51,5 +53,30 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } } } + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]<254){ + orbd[r] += 16; + if(orbd[r]>254){ + orbd[r] = 0; + orbl[r] = rand()%255; + } + //orbl[r] += 1; + //orbl[r] = orbl[r]%255; + } else { + orbd[r] = 0; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/graphics.c b/src/graphics.c index fb3d384..917d267 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1341,6 +1341,8 @@ void xor_rect(pixel *vid, int x, int y, int w, int h) void draw_parts(pixel *vid) { int i, x, y, t, nx, ny, r, s; + int orbd[4] = {0, 0, 0, 0}; + int orbl[4] = {0, 0, 0, 0}; int cr, cg, cb; float fr, fg, fb; float pt = R_TEMP; @@ -1921,32 +1923,76 @@ void draw_parts(pixel *vid) } } } - else if (t==PT_PRTI && DEBUG_MODE) - { - blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); - if (mousex==(nx) && mousey==(ny)) - { - int z; - for (z = 0; z<NPART; z++) { - if (parts[z].type) - { - if (parts[z].type==PT_PRTO&&parts[z].tmp==parts[i].tmp) - xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid); + else if (t==PT_PRTI) + { + int nxo = 0; + int nyo = 0; + int fire_rv = 0; + float drad = 0.0f; + float ddist = 0.0f; + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + ddist = ((float)orbd[r])/16.0f; + drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f; + nxo = ddist*cos(drad); + nyo = ddist*sin(drad); + addpixel(vid, nx+nxo, ny+nyo, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 255-orbd[r]); + if(cmode == CM_FIRE){ + fire_rv = fire_r[(ny+nyo)/CELL][(nx+nxo)/CELL]; + fire_rv += (255-orbd[r])/32; + if(fire_rv>255) fire_rv = 255; + fire_r[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_rv; + } + addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200); + } + if(DEBUG_MODE){ + blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); + if (mousex==(nx) && mousey==(ny)) + { + int z; + for (z = 0; z<NPART; z++) { + if (parts[z].type) + { + if (parts[z].type==PT_PRTO&&parts[z].tmp==parts[i].tmp) + xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid); + } } } } } - else if (t==PT_PRTO && DEBUG_MODE) - { - blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); - if (mousex==(nx) && mousey==(ny)) - { - int z; - for (z = 0; z<NPART; z++) { - if (parts[z].type) - { - if (parts[z].type==PT_PRTI&&parts[z].tmp==parts[i].tmp) - xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid); + else if (t==PT_PRTO) + { + int nxo = 0; + int nyo = 0; + int fire_bv = 0; + float drad = 0.0f; + float ddist = 0.0f; + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + ddist = ((float)orbd[r])/16.0f; + drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f; + nxo = ddist*cos(drad); + nyo = ddist*sin(drad); + addpixel(vid, nx+nxo, ny+nyo, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 255-orbd[r]); + if(cmode == CM_FIRE){ + fire_bv = fire_b[(ny+nyo)/CELL][(nx+nxo)/CELL]; + fire_bv += (255-orbd[r])/32; + if(fire_bv>255) fire_bv = 255; + fire_b[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_bv; + } + addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200); + } + if(DEBUG_MODE){ + blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); + if (mousex==(nx) && mousey==(ny)) + { + int z; + for (z = 0; z<NPART; z++) { + if (parts[z].type) + { + if (parts[z].type==PT_PRTI&&parts[z].tmp==parts[i].tmp) + xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid); + } } } } diff --git a/src/powder.c b/src/powder.c index 23de4ff..09a44a8 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1370,7 +1370,7 @@ void update_particles_i(pixel *vid, int start, int inc) //printf("parts[%d].type: %d\n", i, parts[i].type); - if (parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT) + if (parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT && t!=PT_PRTO && t!=PT_PRTI) { if (!(parts[i].life==10&&(t==PT_SWCH||t==PT_LCRY||t==PT_PCLN||t==PT_HSWC||t==PT_PUMP))) parts[i].life--; @@ -3076,3 +3076,43 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl return ndata; } +#if defined(WIN32) && !defined(__GNUC__) +_inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]) +#else +inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]) +#endif +{ + resblock1[0] = (block1&0x000000FF); + resblock1[1] = (block1&0x0000FF00)>>8; + resblock1[2] = (block1&0x00FF0000)>>16; + resblock1[3] = (block1&0xFF000000)>>24; + + resblock2[0] = (block2&0x000000FF); + resblock2[1] = (block2&0x0000FF00)>>8; + resblock2[2] = (block2&0x00FF0000)>>16; + resblock2[3] = (block2&0xFF000000)>>24; +} + +#if defined(WIN32) && !defined(__GNUC__) +_inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) +#else +inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) +#endif +{ + int block1tmp = 0; + int block2tmp = 0; + + block1tmp = (resblock1[0]&0xFF); + block1tmp |= (resblock1[1]&0xFF)<<8; + block1tmp |= (resblock1[2]&0xFF)<<16; + block1tmp |= (resblock1[3]&0xFF)<<24; + + block2tmp = (resblock2[0]&0xFF); + block2tmp |= (resblock2[1]&0xFF)<<8; + block2tmp |= (resblock2[2]&0xFF)<<16; + block2tmp |= (resblock2[3]&0xFF)<<24; + + *block1 = block1tmp; + *block2 = block2tmp; +} + |
