diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-21 16:25:14 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-21 16:25:14 (GMT) |
| commit | c1eb40af61fc04a2db8971bbf233ddb0f9f4a2b5 (patch) | |
| tree | d7715f19ae87021d98d2178faf13dc20b2bacbb4 /src | |
| parent | 29fa590f000aee805c74481fc52b6ebc30226341 (diff) | |
| download | powder-c1eb40af61fc04a2db8971bbf233ddb0f9f4a2b5.zip powder-c1eb40af61fc04a2db8971bbf233ddb0f9f4a2b5.tar.gz | |
Fix gravity field drawing
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/graphics.c b/src/graphics.c index 034df37..2ca21cc 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1519,22 +1519,23 @@ void draw_grav_zones(pixel * vid) void draw_grav(pixel *vid) { - int x, y, i; + int x, y, i, ca; float nx, ny, dist; for (y=0; y<YRES/CELL; y++) { for (x=0; x<XRES/CELL; x++) { - if(fabsf(gravpf[(y*XRES)+x]) <= 0.001f && fabsf(gravyf[((y*CELL)*XRES)+(x*CELL)]) <= 0.001f) + ca = ((y*CELL)*XRES)+(x*CELL); + if(fabsf(gravpf[ca]) <= 0.001f && fabsf(gravyf[ca]) <= 0.001f) continue; nx = x*CELL; ny = y*CELL; - dist = fabsf(gravyf[(y*XRES)+x])+fabsf(gravxf[(y*XRES)+x]); + dist = fabsf(gravyf[ca])+fabsf(gravxf[ca]); for(i = 0; i < 4; i++) { - nx -= gravxf[((y*CELL)*XRES)+(x*CELL)]*0.5f; - ny -= gravyf[((y*CELL)*XRES)+(x*CELL)]*0.5f; + nx -= gravxf[ca]*0.5f; + ny -= gravyf[ca]*0.5f; addpixel(vid, (int)(nx+0.5f), (int)(ny+0.5f), 255, 255, 255, (int)(dist*20.0f)); } } |
