diff options
-rw-r--r-- | xd.c | 85 |
1 files changed, 84 insertions, 1 deletions
@@ -5085,11 +5085,14 @@ static void FireworkDemo(void) */ #define MAX_DROPS 40 +#define MAX_DRIBBLES 5 +#define DRIBBLE_LEN 30 #define MAX_RADIUS 40 static void RainDemo(void) { static int init = FALSE; + static unsigned cycle; typedef struct { @@ -5101,7 +5104,17 @@ static void RainDemo(void) static Drop drop[MAX_DROPS]; - int f; + typedef struct + { + int alive; + int x,y; + int lastx[DRIBBLE_LEN]; + int life; + } Dribble; + + static Dribble dribble[MAX_DRIBBLES]; + + int f, r; if (!init) { @@ -5126,6 +5139,71 @@ static void RainDemo(void) } } + if (RND(100) > 98) + { + for(f = 0; f < MAX_DRIBBLES && dribble[f].alive; f++) + { + } + + if (f < MAX_DRIBBLES) + { + dribble[f].alive = TRUE; + dribble[f].life = height + DRIBBLE_LEN; + dribble[f].y = 0; + dribble[f].x = RND(width); + + for(r = 0; r < DRIBBLE_LEN; r++) + { + dribble[f].lastx[r] = dribble[f].x; + } + } + } + + for(f = 0; f < MAX_DRIBBLES; f++) + { + if (dribble[f].alive) + { + FCircle(dribble[f].x, dribble[f].y, 3, blue); + + for(r = 0; r < DRIBBLE_LEN; r++) + { + Plot(dribble[f].lastx[r], dribble[f].y - DRIBBLE_LEN + r, blue); + } + } + } + + if ((cycle % 5) == 0) + { + for(f = 0; f < MAX_DRIBBLES; f++) + { + if (dribble[f].alive) + { + if (dribble[f].life > 0) + { + dribble[f].y++; + dribble[f].x += RND(3) - 1; + dribble[f].life--; + + for(r = 0; r < DRIBBLE_LEN; r++) + { + if (r < DRIBBLE_LEN - 1) + { + dribble[f].lastx[r] = dribble[f].lastx[r+1]; + } + else + { + dribble[f].lastx[r] = dribble[f].x; + } + } + } + else + { + dribble[f].alive = FALSE; + } + } + } + } + for(f = 0; f < MAX_DROPS; f++) { if (drop[f].alive) @@ -5152,9 +5230,14 @@ static void RainDemo(void) } } } + + cycle++; } #undef MAX_DROPS +#undef MAX_DRIBBLES +#undef DRIBBLE_LEN +#undef MAX_RADIUS /* END OF FILE */ |