diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 13:57:32 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 13:57:32 (GMT) |
| commit | 9b9d6283744c2164d90fece77366adf8d13abcd3 (patch) | |
| tree | f30a728cd17e605d6f2595da153f191651a79291 /src | |
| parent | dd2d06425e80193d3bf59df0d2600d21bdde49ce (diff) | |
| download | powder-9b9d6283744c2164d90fece77366adf8d13abcd3.zip powder-9b9d6283744c2164d90fece77366adf8d13abcd3.tar.gz | |
Improvements to Wire
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/wire.c | 30 | ||||
| -rw-r--r-- | src/powder.c | 31 |
2 files changed, 37 insertions, 24 deletions
diff --git a/src/elements/wire.c b/src/elements/wire.c index 920ddc9..f56e469 100644 --- a/src/elements/wire.c +++ b/src/elements/wire.c @@ -2,7 +2,6 @@ int update_WIRE(UPDATE_FUNC_ARGS) { int s,r,rx,ry,count; - s=pmap[y][x]; /* 0: wire 1: spark head @@ -10,23 +9,32 @@ int update_WIRE(UPDATE_FUNC_ARGS) { tmp is previous state, ctype is current state */ - //parts[s>>8].tmp=parts[s>>8].ctype; - parts[s>>8].ctype=0; - if(parts[s>>8].tmp==1){parts[s>>8].ctype=2; return 0;} - if(parts[s>>8].tmp==2){parts[s>>8].ctype=0; return 0;} + //parts[i].tmp=parts[i].ctype; + parts[i].ctype=0; + if(parts[i].tmp==1) + { + parts[i].ctype=2; + } + if(parts[i].tmp==2) + { + parts[i].ctype=0; + } count=0; for(rx=-1; rx<2; rx++) for(ry=-1; ry<2; ry++) + { + if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { - if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && pmap[y+ry][x+rx] && (rx!=0 || ry!=0) && (pmap[y+ry][x+rx]&0xFF)!=0xFF) - { r = pmap[y+ry][x+rx]; - if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[s>>8].ctype=1; parts[r>>8].life=0; return 0;} - if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1){count++;} - } + if ((r>>8)>=NPART || !r) + continue; + if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;} + else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);} + else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;} } + } if(count==1 || count==2) - parts[s>>8].ctype=1; + parts[i].ctype=1; return 0; } diff --git a/src/powder.c b/src/powder.c index 8e5139a..4add0b6 100644 --- a/src/powder.c +++ b/src/powder.c @@ -7,6 +7,8 @@ int gravwl_timeout = 0; +int ISWIRE = 0; + float player[28]; //[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned float player2[28]; @@ -709,11 +711,6 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a if (t==PT_SPRK) { - if((pmap[y][x]>>8)==PT_WIRE) - { - parts[pmap[y][x]>>8].ctype=1; - return -1; - } if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) return -1; if (parts[pmap[y][x]>>8].life!=0) @@ -1472,14 +1469,18 @@ void update_particles_i(pixel *vid, int start, int inc) } } //wire! - for (nx=0; nx<XRES; nx++) - for (ny=0; ny<YRES; ny++) - { - r = pmap[ny][nx]; - if ((r>>8)>=NPART || !r) - continue; - parts[r>>8].tmp=parts[r>>8].ctype; - } + if(ISWIRE == 1) + { + ISWIRE = 0; + for (nx=0; nx<XRES; nx++) + for (ny=0; ny<YRES; ny++) + { + r = pmap[ny][nx]; + if ((r>>8)>=NPART || !r) + continue; + parts[r>>8].tmp=parts[r>>8].ctype; + } + } //game of life! if (ISGOL==1&&++CGOL>=GSPEED)//GSPEED is frames per generation { @@ -1887,6 +1888,10 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].temp = restrict_flt(parts[i].temp-50.0f, MIN_TEMP, MAX_TEMP); ISGOL=1;//means there is a life particle on screen } + if (t==PT_WIRE) + { + ISWIRE = 1; + } //spark updates from walls if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK) { |
