14 struct dust_mote motes[N_DUST_MOTES];
16 // lower bound to ensure that we don't lose precision when wrapping.
23 for(i=0; i<N_DUST_MOTES; i++) {
24 motes[i].x = frnd()*(XSIZE-5);
25 motes[i].y = frnd()*(YSIZE-5);
26 motes[i].z = MAX_DUST_DEPTH*sqrt(frnd());
27 b = (MAX_DUST_DEPTH - motes[i].z) * 255.0 / MAX_DUST_DEPTH;
28 motes[i].color = SDL_MapRGB(surf_screen->format, b, b, b);
31 zero = pow(-10, ceil(log10(XSIZE)) - FLT_DIG);
35 move_dust(float ticks)
38 float xscroll = screendx * ticks;
39 float yscroll = screendy * ticks;
41 for(i=0; i<N_DUST_MOTES; i++) {
42 motes[i].x -= xscroll / (1.3 + motes[i].z);
43 if(motes[i].x >= XSIZE) motes[i].x -= XSIZE;
44 else if(motes[i].x < zero) motes[i].x += XSIZE;
46 motes[i].y -= yscroll / (1.3 + motes[i].z);
47 if(motes[i].y >= YSIZE) motes[i].y -= YSIZE;
48 else if(motes[i].y < zero) motes[i].y += YSIZE;
53 draw_dust(SDL_Surface *s)
56 uint16_t *pixels = s->pixels;
57 for(i=0; i<N_DUST_MOTES; i++) {
58 pixels[s->pitch/2*(int)motes[i].y + (int)motes[i].x] = motes[i].color;