Added Cracker changes for adding a triangle brush! :DDD Seems to work without any issues.
This commit is contained in:
parent
d7053422f1
commit
45fe00bef9
@ -85,7 +85,9 @@ extern unsigned char ZSIZE;
|
||||
|
||||
#define CIRCLE_BRUSH 0
|
||||
#define SQUARE_BRUSH 1
|
||||
#define BRUSH_NUM 2
|
||||
#define TRI_BRUSH 2
|
||||
#define BRUSH_NUM 3
|
||||
|
||||
|
||||
//#define LUACONSOLE
|
||||
//#define PYCONSOLE
|
||||
|
@ -969,6 +969,8 @@ void detach(int i);
|
||||
|
||||
void part_change_type(int i, int x, int y, int t);
|
||||
|
||||
int InCurrentBrush(int i, int j, int rx, int ry);
|
||||
|
||||
int create_part(int p, int x, int y, int t);
|
||||
|
||||
void delete_part(int x, int y);
|
||||
|
@ -3567,7 +3567,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if(y+j>=0 && x+i>=0 && x+i<XRES && y+j<YRES)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)){
|
||||
if (InCurrentBrush(i, j, rx, ry)){
|
||||
rp = pmap[y+j][x+i];
|
||||
if ((rp>>8)>=NPART || !rp)
|
||||
continue;
|
||||
@ -4235,6 +4235,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
|
||||
}
|
||||
}
|
||||
else if (CURRENT_BRUSH==CIRCLE_BRUSH)
|
||||
{
|
||||
for (j=0; j<=ry; j++)
|
||||
for (i=0; i<=rx; i++)
|
||||
if ((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1 && ((pow(i+1,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))>1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1))
|
||||
@ -4244,6 +4245,17 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
|
||||
if (i) xor_pixel(x-i, y+j, vid);
|
||||
if (i&&j) xor_pixel(x-i, y-j, vid);
|
||||
}
|
||||
}
|
||||
else if (CURRENT_BRUSH==TRI_BRUSH)
|
||||
{
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) && (j+1>ry || (j-1 < (((-2.0*ry)/rx)*i) -ry) || ( j-1 < (((-2.0*ry)/(-rx))*i)-ry )) )
|
||||
{
|
||||
xor_pixel(x+i, y+j, vid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else //wall cursor
|
||||
{
|
||||
|
26
src/powder.c
26
src/powder.c
@ -2687,7 +2687,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
delete_part(x+i, y+j);
|
||||
return 1;
|
||||
}
|
||||
@ -2702,7 +2702,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
{
|
||||
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
|
||||
continue;
|
||||
@ -2726,7 +2726,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
delete_part(x+i, y+j);
|
||||
SLALT = stemp;
|
||||
return 1;
|
||||
@ -2748,7 +2748,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
{
|
||||
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
|
||||
continue;
|
||||
@ -2773,12 +2773,26 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
else
|
||||
for (j=-ry; j<=ry; j++)
|
||||
for (i=-rx; i<=rx; i++)
|
||||
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
|
||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
||||
if (create_part(-2, x+i, y+j, c)==-1)
|
||||
f = 1;
|
||||
return !f;
|
||||
}
|
||||
|
||||
int InCurrentBrush(int i, int j, int rx, int ry)
|
||||
{
|
||||
switch(CURRENT_BRUSH)
|
||||
{
|
||||
case CIRCLE_BRUSH:
|
||||
return ((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1);
|
||||
break;
|
||||
case SQUARE_BRUSH:
|
||||
return (i*j<=ry*rx);
|
||||
break;
|
||||
case TRI_BRUSH:
|
||||
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)
|
||||
{
|
||||
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
|
||||
|
Loading…
Reference in New Issue
Block a user