Fixed SWCH for real. Fix repeating spark while creating it. Adjustable x and y for brushes.
This commit is contained in:
parent
435f71c781
commit
c1182db42d
@ -137,7 +137,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height);
|
||||
|
||||
int render_thumb(void *thumb, int size, int bzip2, pixel *vid_buf, int px, int py, int scl);
|
||||
|
||||
void render_cursor(pixel *vid, int x, int y, int t, int r);
|
||||
void render_cursor(pixel *vid, int x, int y, int t, float rx, float ry);
|
||||
|
||||
void sdl_open(void);
|
||||
|
||||
|
@ -540,8 +540,8 @@ void create_box(int x1, int y1, int x2, int y2, int c);
|
||||
|
||||
int flood_parts(int x, int y, int c, int cm, int bm);
|
||||
|
||||
int create_parts(int x, int y, int r, int c);
|
||||
int create_parts(int x, int y, float rx, float ry, int c);
|
||||
|
||||
void create_line(int x1, int y1, int x2, int y2, int r, int c);
|
||||
void create_line(int x1, int y1, int x2, int y2, float rx, float ry, int c);
|
||||
|
||||
#endif
|
||||
|
@ -2838,25 +2838,33 @@ corrupt:
|
||||
return 1;
|
||||
}
|
||||
|
||||
void render_cursor(pixel *vid, int x, int y, int t, int r)
|
||||
void render_cursor(pixel *vid, int x, int y, int t, float rx, float ry)
|
||||
{
|
||||
int i,j,c;
|
||||
if(t<PT_NUM||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM)
|
||||
{
|
||||
if(r<=0)
|
||||
if(rx<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
else if(ry<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
if(rx+ry<=0)
|
||||
xor_pixel(x, y, vid);
|
||||
else if(CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-r; j<=r; j++)
|
||||
{
|
||||
xor_pixel(x+r, y+j, vid);
|
||||
xor_pixel(x-r, y+j, vid);
|
||||
if(abs(j)<r) xor_pixel(x+j, y-r, vid);
|
||||
if(abs(j)<r) xor_pixel(x+j, y+r, vid);
|
||||
for(j=0; j<=ry; j++)
|
||||
for(i=0; i<=rx; i++)
|
||||
if(i*j<=ry*rx && ((i+1)>rx || (j+1)>ry))
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
xor_pixel(x-i, y-j, vid);
|
||||
if(i&&j)xor_pixel(x+i, y-j, vid);
|
||||
if(i&&j)xor_pixel(x-i, y+j, vid);
|
||||
}
|
||||
}
|
||||
else if(CURRENT_BRUSH==CIRCLE_BRUSH)
|
||||
for(j=0; j<=r; j++)
|
||||
for(i=0; i<=r; i++)
|
||||
if(i*i+j*j<=r*r && ((i+1)*(i+1)+j*j>r*r || i*i+(j+1)*(j+1)>r*r))
|
||||
for(j=0; j<=ry; j++)
|
||||
for(i=0; i<=rx; i++)
|
||||
if((i*i)/(rx*rx)+(j*j)/(ry*rx)<=1 && (((i+1)*(i+1))/(rx*rx)+(j*j)/(ry*rx)>1 || ((i*i)/(rx*rx)+((j+1)*(j+1))/(ry*ry)>1)))
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
if(j) xor_pixel(x+i, y-j, vid);
|
||||
@ -2867,7 +2875,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int r)
|
||||
else
|
||||
{
|
||||
int tc;
|
||||
c = (r/CELL) * CELL;
|
||||
c = (rx/CELL) * CELL;
|
||||
x = (x/CELL) * CELL;
|
||||
y = (y/CELL) * CELL;
|
||||
|
||||
|
102
src/main.c
102
src/main.c
@ -993,8 +993,8 @@ int main(int argc, char *argv[])
|
||||
int vs = 0;
|
||||
#endif
|
||||
int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
||||
int da = 0, db = 0, it = 2047, mx, my, bs = 2;
|
||||
float nfvx, nfvy;
|
||||
int da = 0, db = 0, it = 2047, mx, my;
|
||||
float nfvx, nfvy, bsx = 2, bsy = 2;
|
||||
int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0;
|
||||
void *load_data=NULL;
|
||||
pixel *load_img=NULL;//, *fbi_img=NULL;
|
||||
@ -1292,14 +1292,32 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
||||
bs -= 1;
|
||||
if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
||||
{
|
||||
bsx -= 1;
|
||||
bsy -= 1;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
bsx -= 1;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
||||
{
|
||||
bsy -= 1;
|
||||
}
|
||||
else
|
||||
bs -= ceil((bs/5)+0.5f);
|
||||
if(bs>1224)
|
||||
bs = 1224;
|
||||
if(bs<0)
|
||||
bs = 0;
|
||||
{
|
||||
bsx -= ceil((bsx/5)+0.5f);
|
||||
bsy -= ceil((bsy/5)+0.5f);
|
||||
}
|
||||
if(bsx>1180)
|
||||
bsx = 1180;
|
||||
if(bsy>1180)
|
||||
bsy = 1180;
|
||||
if(bsx<0)
|
||||
bsx = 0;
|
||||
if(bsy<0)
|
||||
bsy = 0;
|
||||
}
|
||||
}
|
||||
if(sdl_key==SDLK_RIGHTBRACKET) {
|
||||
@ -1314,14 +1332,32 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
||||
bs += 1;
|
||||
if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
||||
{
|
||||
bsx += 1;
|
||||
bsy += 1;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
bsx += 1;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
||||
{
|
||||
bsy += 1;
|
||||
}
|
||||
else
|
||||
bs += ceil((bs/5)+0.5f);
|
||||
if(bs>1224)
|
||||
bs = 1224;
|
||||
if(bs<0)
|
||||
bs = 0;
|
||||
{
|
||||
bsx += ceil((bsx/5)+0.5f);
|
||||
bsy += ceil((bsy/5)+0.5f);
|
||||
}
|
||||
if(bsx>1180)
|
||||
bsx = 1180;
|
||||
if(bsy>1180)
|
||||
bsy = 1180;
|
||||
if(bsx<0)
|
||||
bsx = 0;
|
||||
if(bsy<0)
|
||||
bsy = 0;
|
||||
}
|
||||
}
|
||||
if(sdl_key==SDLK_INSERT)
|
||||
@ -1407,11 +1443,27 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
bs += sdl_wheel;
|
||||
if(bs>1224)
|
||||
bs = 1224;
|
||||
if(bs<0)
|
||||
bs = 0;
|
||||
if(!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
||||
{
|
||||
bsx += sdl_wheel;
|
||||
bsy += sdl_wheel;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
bsx += sdl_wheel;
|
||||
}
|
||||
else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
||||
{
|
||||
bsy += sdl_wheel;
|
||||
}
|
||||
if(bsx>1180)
|
||||
bsx = 1180;
|
||||
if(bsx<0)
|
||||
bsx = 0;
|
||||
if(bsy>1180)
|
||||
bsy = 1180;
|
||||
if(bsy<0)
|
||||
bsy = 0;
|
||||
sdl_wheel = 0;
|
||||
/*if(su >= PT_NUM) {
|
||||
if(sl < PT_NUM)
|
||||
@ -1846,7 +1898,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
create_line(lx, ly, x, y, bs, c);
|
||||
create_line(lx, ly, x, y, bsx, bsy, c);
|
||||
lx = x;
|
||||
ly = y;
|
||||
}
|
||||
@ -1920,7 +1972,7 @@ int main(int argc, char *argv[])
|
||||
cb_emap[cby][cbx] = emap[cby][cbx];
|
||||
}
|
||||
|
||||
create_parts(x, y, bs, c);
|
||||
create_parts(x, y, bsx, bsy, c);
|
||||
lx = x;
|
||||
ly = y;
|
||||
lb = b;
|
||||
@ -1940,7 +1992,7 @@ int main(int argc, char *argv[])
|
||||
if(lm == 1)
|
||||
{
|
||||
if(c!=127 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=4)
|
||||
create_line(lx, ly, x, y, bs, c);
|
||||
create_line(lx, ly, x, y, bsx, bsy, c);
|
||||
}
|
||||
else
|
||||
create_box(lx, ly, x, y, c);
|
||||
@ -1964,7 +2016,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(zoom_en!=1 && !load_mode && !save_mode)
|
||||
{
|
||||
render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bs);
|
||||
render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy);
|
||||
mousex = mx/sdl_scale;
|
||||
mousey = my/sdl_scale;
|
||||
}
|
||||
|
72
src/powder.c
72
src/powder.c
@ -441,6 +441,8 @@ inline int create_part(int p, int x, int y, int t)
|
||||
(pmap[y][x]&0xFF)!=PT_IRON &&
|
||||
(pmap[y][x]&0xFF)!=PT_INWR)
|
||||
return -1;
|
||||
if(parts[pmap[y][x]>>8].life!=0)
|
||||
return -1;
|
||||
parts[pmap[y][x]>>8].type = PT_SPRK;
|
||||
parts[pmap[y][x]>>8].life = 4;
|
||||
parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF;
|
||||
@ -1226,7 +1228,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
nearp = nearest_part(i, PT_ETRD);
|
||||
if(nearp!=-1&&parts_avg(i, nearp)!=PT_INSL)
|
||||
{
|
||||
create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, PT_PLSM);
|
||||
create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM);
|
||||
t = parts[i].type = PT_ETRD;
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
@ -2698,7 +2700,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
}
|
||||
if(t==PT_SWCH)
|
||||
if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11)
|
||||
if((parts[i].life>0&&parts[i].life<10)|| parts[i].life > 10)
|
||||
{
|
||||
parts[i].life--;
|
||||
}
|
||||
@ -2795,7 +2797,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
{
|
||||
parts[r>>8].type = PT_SWCH;
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].life = 9;
|
||||
}
|
||||
}
|
||||
pavg = parts_avg(i, r>>8);
|
||||
@ -2806,7 +2808,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
parts[r>>8].life = 10;
|
||||
if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL)
|
||||
parts[r>>8].life = 9;
|
||||
if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life >= 10&&pavg != PT_INSL) //Life can be 11 too, so don't just check for 10
|
||||
if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life == 10&&pavg != PT_INSL)
|
||||
{
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
parts[r>>8].ctype = PT_SWCH;
|
||||
@ -2896,7 +2898,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=1)
|
||||
{
|
||||
parts[i].type = PT_SWCH;
|
||||
parts[i].life = 11;
|
||||
parts[i].life = 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3112,7 +3114,7 @@ killed:
|
||||
else
|
||||
{
|
||||
if(player[2] == SPC_AIR)
|
||||
create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, SPC_AIR);
|
||||
create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
|
||||
else
|
||||
create_part(-1, nx, ny, player[2]);
|
||||
|
||||
@ -4212,7 +4214,7 @@ void create_box(int x1, int y1, int x2, int y2, int c)
|
||||
}
|
||||
for(j=y1; j<=y2; j++)
|
||||
for(i=x1; i<=x2; i++)
|
||||
create_parts(i, j, 1, c);
|
||||
create_parts(i, j, 1, 1, c);
|
||||
}
|
||||
|
||||
int flood_parts(int x, int y, int c, int cm, int bm)
|
||||
@ -4268,7 +4270,7 @@ int flood_parts(int x, int y, int c, int cm, int bm)
|
||||
|
||||
// fill span
|
||||
for(x=x1; x<=x2; x++)
|
||||
if(!create_parts(x, y, 0, co))
|
||||
if(!create_parts(x, y, 0, 0, co))
|
||||
return 0;
|
||||
|
||||
// fill children
|
||||
@ -4285,7 +4287,7 @@ int flood_parts(int x, int y, int c, int cm, int bm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int create_parts(int x, int y, int r, int c)
|
||||
int create_parts(int x, int y, float rx, float ry, int c)
|
||||
{
|
||||
int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0; //n;
|
||||
|
||||
@ -4374,14 +4376,14 @@ int create_parts(int x, int y, int r, int c)
|
||||
}
|
||||
if(dw==1)
|
||||
{
|
||||
r = r/CELL;
|
||||
rx = rx/CELL;
|
||||
x = x/CELL;
|
||||
y = y/CELL;
|
||||
x -= r/2;
|
||||
y -= r/2;
|
||||
for (ox=x; ox<=x+r; ox++)
|
||||
x -= rx/2;
|
||||
y -= rx/2;
|
||||
for (ox=x; ox<=x+rx; ox++)
|
||||
{
|
||||
for (oy=y; oy<=y+r; oy++)
|
||||
for (oy=y; oy<=y+rx; oy++)
|
||||
{
|
||||
if(ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
|
||||
{
|
||||
@ -4400,26 +4402,26 @@ int create_parts(int x, int y, int r, int c)
|
||||
}
|
||||
if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
|
||||
{
|
||||
for(j=-r; j<=r; j++)
|
||||
for(i=-r; i<=r; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && i*i+j*j<=r*r)||CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-ry; j<=ry; j++)
|
||||
for(i=-rx; i<=rx; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*rx)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
delete_part(x+i, y+j);
|
||||
return 1;
|
||||
}
|
||||
if(REPLACE_MODE)
|
||||
{
|
||||
for(j=-r; j<=r; j++)
|
||||
for(i=-r; i<=r; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && i*i+j*j<=r*r)||CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-ry; j<=ry; j++)
|
||||
for(i=-rx; i<=rx; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*rx)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
delete_part(x+i, y+j);
|
||||
if(c==0)
|
||||
return 1;
|
||||
}
|
||||
if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM)
|
||||
{
|
||||
for(j=-r; j<=r; j++)
|
||||
for(i=-r; i<=r; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && i*i+j*j<=r*r)||CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-ry; j<=ry; j++)
|
||||
for(i=-rx; i<=rx; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*rx)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
create_part(-1, x+i, y+j, c);
|
||||
return 1;
|
||||
}
|
||||
@ -4428,23 +4430,23 @@ int create_parts(int x, int y, int r, int c)
|
||||
{
|
||||
stemp = SLALT;
|
||||
SLALT = 0;
|
||||
for(j=-r; j<=r; j++)
|
||||
for(i=-r; i<=r; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && i*i+j*j<=r*r)||CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-ry; j<=ry; j++)
|
||||
for(i=-rx; i<=rx; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*rx)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
delete_part(x+i, y+j);
|
||||
SLALT = stemp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(j=-r; j<=r; j++)
|
||||
for(i=-r; i<=r; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && i*i+j*j<=r*r)||CURRENT_BRUSH==SQUARE_BRUSH)
|
||||
for(j=-ry; j<=ry; j++)
|
||||
for(i=-rx; i<=rx; i++)
|
||||
if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*rx)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if(create_part(-1, x+i, y+j, c)==-1)
|
||||
f = 1;
|
||||
return !f;
|
||||
}
|
||||
|
||||
void create_line(int x1, int y1, int x2, int y2, int r, int c)
|
||||
void create_line(int x1, int y1, int x2, int y2, float rx, float ry, int c)
|
||||
{
|
||||
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
|
||||
float e, de;
|
||||
@ -4478,19 +4480,19 @@ void create_line(int x1, int y1, int x2, int y2, int r, int c)
|
||||
for(x=x1; x<=x2; x++)
|
||||
{
|
||||
if(cp)
|
||||
create_parts(y, x, r, c);
|
||||
create_parts(y, x, rx, ry, c);
|
||||
else
|
||||
create_parts(x, y, r, c);
|
||||
create_parts(x, y, rx, ry, c);
|
||||
e += de;
|
||||
if(e >= 0.5f)
|
||||
{
|
||||
y += sy;
|
||||
if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r)
|
||||
if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !(rx+ry))
|
||||
{
|
||||
if(cp)
|
||||
create_parts(y, x, r, c);
|
||||
create_parts(y, x, rx, ry, c);
|
||||
else
|
||||
create_parts(x, y, r, c);
|
||||
create_parts(x, y, rx, ry, c);
|
||||
}
|
||||
e -= 1.0f;
|
||||
}
|
||||
|
Reference in New Issue
Block a user