summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCate <cate@cate-6sh2.(none)>2011-07-12 15:28:33 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-07-12 17:46:33 (GMT)
commitd3452b01c8aad35e6d55523323247eeb114dc7d1 (patch)
tree82eae01ee6e63d47b944ad0eb53937100d5a73af /src
parent7480442c67682c40672dd862a921972e816ce59e (diff)
downloadpowder-d3452b01c8aad35e6d55523323247eeb114dc7d1.zip
powder-d3452b01c8aad35e6d55523323247eeb114dc7d1.tar.gz
OMG FIXES. Lots of fixes for triangle brush to make sure it works, from Cracker. Edited CLST to prevent "popcorning" when its float hits weird numbers. Also fixed it so it freezes nicely when cooled. Fingers are back! :DDD
Diffstat (limited to 'src')
-rw-r--r--src/elements/clst.c11
-rw-r--r--src/graphics.c13
-rw-r--r--src/main.c4
-rw-r--r--src/powder.c3
4 files changed, 22 insertions, 9 deletions
diff --git a/src/elements/clst.c b/src/elements/clst.c
index db0eb7c..15b5624 100644
--- a/src/elements/clst.c
+++ b/src/elements/clst.c
@@ -16,7 +16,16 @@ int update_CLST(UPDATE_FUNC_ARGS) {
}
if ((r&0xFF)==PT_CLST)
{
- parts[i].vx += 0.01*rx; parts[i].vy += 0.01*ry;
+ if(parts[i].temp <195)
+ cxy = 0.05;
+ if(parts[i].temp >= 195 && parts[i].temp <295)
+ cxy = 0.015;
+ if(parts[i].temp >= 295 && parts[i].temp <350)
+ cxy = 0.01;
+ if(parts[i].temp > 350)
+ cxy = 0.005;
+ parts[i].vx += cxy*rx;
+ parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005.
}
}
return 0;
diff --git a/src/graphics.c b/src/graphics.c
index 2013de6..40f57c1 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -4247,13 +4247,14 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
}
}
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);
- }
+ for (i=-rx; i<=0; i++)
+ if ((j <= ry ) && ( j >= (((-2.0*ry)/(rx))*i)-ry ) && (j+1>ry || ( j-1 < (((-2.0*ry)/(rx))*i)-ry )) )
+ {
+ xor_pixel(x+i, y+j, vid);
+ if (i) xor_pixel(x-i, y+j, vid);
+ }
}
}
diff --git a/src/main.c b/src/main.c
index 9d68465..075cab0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3055,7 +3055,7 @@ int main(int argc, char *argv[])
{
for (j=-bsy; j<=bsy; j++)
for (i=-bsx; i<=bsx; i++)
- if (lx+i>=0 && ly+j>=0 && lx+i<XRES && ly+j<YRES && ((CURRENT_BRUSH==CIRCLE_BRUSH && pow(i,2)*pow(bsy,2)+pow(j,2)*pow(bsx,2)<=pow(bsx,2)*pow(bsy,2))||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)))
+ if (x+i>0 && y+j>0 && x+i<XRES && y+j<YRES && InCurrentBrush(i,j,bsx,bsy))
{
vx[(ly+j)/CELL][(lx+i)/CELL] += (line_x-lx)*0.002f;
vy[(ly+j)/CELL][(lx+i)/CELL] += (line_y-ly)*0.002f;
@@ -3075,7 +3075,7 @@ int main(int argc, char *argv[])
{
for (j=-bsy; j<=bsy; j++)
for (i=-bsx; i<=bsx; i++)
- if (x+i>0 && y+j>0 && x+i<XRES && y+j<YRES && ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(bsx,2))+(pow(j,2))/(pow(bsy,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)))
+ if (x+i>0 && y+j>0 && x+i<XRES && y+j<YRES && InCurrentBrush(i,j,bsx,bsy))
{
vx[(y+j)/CELL][(x+i)/CELL] += (x-lx)*0.01f;
vy[(y+j)/CELL][(x+i)/CELL] += (y-ly)*0.01f;
diff --git a/src/powder.c b/src/powder.c
index 6bce790..f83c790 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -2791,6 +2791,9 @@ int InCurrentBrush(int i, int j, int rx, int ry)
case TRI_BRUSH:
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;
break;
+ default:
+ return 0;
+ break;
}
}
void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c)