X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=inline;f=dust.c;h=96a5805601b5d99841e5fed771f1e57530ff97e7;hb=1796973cc22433f9b875b8b6d945fc914a78e14d;hp=3a9f2465081ffe184f2e537fd18c88c0133e0dde;hpb=3cfde1edc98388c11d4efbbba7c8deaf56c4b1ae;p=vor.git diff --git a/dust.c b/dust.c index 3a9f246..96a5805 100644 --- a/dust.c +++ b/dust.c @@ -13,6 +13,9 @@ 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) { @@ -24,21 +27,25 @@ 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 -move_dust(void) +move_dust(float ticks) { int i; - float xscroll = screendx * t_frame; - float yscroll = screendy * t_frame; + float xscroll = screendx * ticks; + float yscroll = screendy * ticks; + for(i=0; i= XSIZE) motes[i].x -= XSIZE; + else if(motes[i].x < zero) motes[i].x += XSIZE; + motes[i].y -= yscroll / (1.3 + motes[i].z); - if(motes[i].y >= XSIZE) motes[i].x -= XSIZE; - else if(motes[i].x < 0) motes[i].x += XSIZE; - if(motes[i].y > YSIZE) motes[i].y -= YSIZE; - else if(motes[i].y < 0) motes[i].y += YSIZE; + if(motes[i].y >= YSIZE) motes[i].y -= YSIZE; + else if(motes[i].y < zero) motes[i].y += YSIZE; } }