14 struct dust_mote motes[N_DUST_MOTES];
20 for(i=0; i<N_DUST_MOTES; i++) {
21 motes[i].x = frnd()*(XSIZE-5);
22 motes[i].y = frnd()*(YSIZE-5);
23 motes[i].z = MAX_DUST_DEPTH*sqrt(frnd());
24 b = (MAX_DUST_DEPTH - motes[i].z) * 255.0 / MAX_DUST_DEPTH;
25 motes[i].color = SDL_MapRGB(surf_screen->format, b, b, b);
30 move_dust(float ticks)
33 float xscroll = screendx * ticks;
34 float yscroll = screendy * ticks;
36 // Originally this code was much simpler, but it would crash sometimes
37 // because the floating point numbers wouldn't always round the same
38 // direction, and we'd ocanially try to draw off the screen.
40 for(i=0; i<N_DUST_MOTES; i++) {
41 motes[i].x -= xscroll / (1.3 + motes[i].z);
42 motes[i].y -= yscroll / (1.3 + motes[i].z);
47 if(motes[i].x > (XSIZE - 0.000001)) {
57 if(motes[i].y > (YSIZE - 0.000001)) {
67 draw_dust(SDL_Surface *s)
70 uint16_t *pixels = s->pixels;
71 for(i=0; i<N_DUST_MOTES; i++) {
72 pixels[s->pitch/2*(int)motes[i].y + (int)motes[i].x] = motes[i].color;