X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=dust.c;h=7b6286732228e755ee2fae7880cb33def25ec3c8;hp=691649d412b821b42f83766a3af059a361b6a4c3;hb=88a9e026caed5568363cefb7d49308b875dc5e4a;hpb=841f94c4182f8dff0253db9bae4922c3c9039a5f diff --git a/dust.c b/dust.c index 691649d..7b62867 100644 --- a/dust.c +++ b/dust.c @@ -27,16 +27,39 @@ init_dust(void) } void -move_dust(void) +move_dust(float ticks) { int i; + float xscroll = screendx * ticks; + float yscroll = screendy * ticks; + + // Originally this code was much simpler, but it would crash sometimes + // because the floating point numbers wouldn't always round the same + // direction, and we'd ocanially try to draw off the screen. + for(i=0; i= 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].x < 0) { + motes[i].x += XSIZE; + } + if(motes[i].x > (XSIZE - 0.000001)) { + motes[i].x -= XSIZE; + if(motes[i].x < 0) { + motes[i].x = 0; + } + } + + if(motes[i].y < 0) { + motes[i].y += YSIZE; + } + if(motes[i].y > (YSIZE - 0.000001)) { + motes[i].y -= YSIZE; + if(motes[i].y < 0) { + motes[i].y = 0; + } + } } }