summaryrefslogtreecommitdiff
path: root/src/graphics.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-04-22 16:06:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-04-22 16:06:09 (GMT)
commit13ff21bb228d131b0b48f81ad57629a4d4756bc2 (patch)
tree06ebde58e8e24170c9b1512957c6e27a692b8bc0 /src/graphics.c
parenta75de307820df32119d02715bbc2f474c5ab6fd8 (diff)
downloadpowder-13ff21bb228d131b0b48f81ad57629a4d4756bc2.zip
powder-13ff21bb228d131b0b48f81ad57629a4d4756bc2.tar.gz
Gravitaaaay (Needs tweeking for performance)
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/graphics.c b/src/graphics.c
index b92f12c..703e972 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1255,6 +1255,30 @@ void draw_air(pixel *vid)
}
}
+void draw_grav(pixel *vid)
+{
+ int x, y, i;
+ float nx, ny, dist;
+
+ for (y=0; y<YRES/CELL; y++)
+ {
+ for (x=0; x<XRES/CELL; x++)
+ {
+ if(fabsf(gravx[y][x]) <= 0.001f && fabsf(gravy[y][x]) <= 0.001f)
+ continue;
+ nx = x*CELL;
+ ny = y*CELL;
+ dist = fabsf(gravx[y][x])+fabsf(gravy[y][x]);
+ for(i = 0; i < 4; i++)
+ {
+ nx -= gravx[y][x]*0.5f;
+ ny -= gravy[y][x]*0.5f;
+ addpixel(vid, (int)(nx+0.5f), (int)(ny+0.5f), 255, 255, 255, (int)(dist*20.0f));
+ }
+ }
+ }
+}
+
void draw_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a) //Draws a line
{
int dx, dy, i, sx, sy, check, e, x, y;