X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=dust.c;h=4eeeb8b034a23f1c4ef8e2c3998801998528eb7e;hp=96a5805601b5d99841e5fed771f1e57530ff97e7;hb=fe549d406b589b1c3db83aeea28c911292a5968e;hpb=1796973cc22433f9b875b8b6d945fc914a78e14d diff --git a/dust.c b/dust.c index 96a5805..4eeeb8b 100644 --- a/dust.c +++ b/dust.c @@ -4,6 +4,7 @@ #include "config.h" #include "globals.h" #include "dust.h" +#include "float.h" #include "mt.h" struct dust_mote { @@ -13,9 +14,6 @@ struct dust_mote { struct dust_mote motes[N_DUST_MOTES]; -// lower bound to ensure that we don't lose precision when wrapping. -static float zero; - void init_dust(void) { @@ -27,8 +25,6 @@ init_dust(void) b = (MAX_DUST_DEPTH - motes[i].z) * 255.0 / MAX_DUST_DEPTH; motes[i].color = SDL_MapRGB(surf_screen->format, b, b, b); } - - zero = pow(-10, ceil(log10(XSIZE)) - FLT_DIG); } void @@ -40,12 +36,10 @@ move_dust(float ticks) for(i=0; i= XSIZE) motes[i].x -= XSIZE; - else if(motes[i].x < zero) motes[i].x += XSIZE; + motes[i].x = fwrap(motes[i].x, XSIZE); motes[i].y -= yscroll / (1.3 + motes[i].z); - if(motes[i].y >= YSIZE) motes[i].y -= YSIZE; - else if(motes[i].y < zero) motes[i].y += YSIZE; + motes[i].y = fwrap(motes[i].y, YSIZE); } }