X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=dust.c;h=ab583953ae0bd928ded3f40b5e153f6c9c626ea7;hp=7b6286732228e755ee2fae7880cb33def25ec3c8;hb=0b5ebc550b1fe83206580ee5fc6d1f0023e38d96;hpb=88a9e026caed5568363cefb7d49308b875dc5e4a diff --git a/dust.c b/dust.c index 7b62867..ab58395 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 { @@ -27,48 +28,27 @@ init_dust(void) } void -move_dust(float ticks) +move_dust(void) { 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. + float xscroll = screendx * t_frame; + float yscroll = screendy * t_frame; for(i=0; i (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; - } - } + motes[i].y -= yscroll / (1.3 + motes[i].z); + motes[i].y = fwrap(motes[i].y, YSIZE); } } void -draw_dust(SDL_Surface *s) +draw_dust(void) { int i; - uint16_t *pixels = s->pixels; + uint16_t *pixels = surf_screen->pixels; for(i=0; ipitch/2*(int)motes[i].y + (int)motes[i].x] = motes[i].color; + pixels[surf_screen->pitch/2*(int)motes[i].y + (int)motes[i].x] = motes[i].color; } }