diff options
author | Ian C <ianc@noddybox.co.uk> | 2018-10-26 06:40:23 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2018-10-26 06:40:23 +0000 |
commit | f90feaa36da1f1b456cb1e92fd2f13d6a9abd5e0 (patch) | |
tree | f431470f9766dadafc878f0c80199f85a77f2510 /xd.c | |
parent | b38b27007edc9d5f012c4fd124646c5043a71a2d (diff) |
Added some extra randomness to the snow demo.
Diffstat (limited to 'xd.c')
-rw-r--r-- | xd.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -4278,23 +4278,34 @@ static void SnowDemo(void) for(f = 0; f < SNOW_FLAKES; f++) { + int dir; + + if (RND(10) > 5) + { + dir = 1; + } + else + { + dir = -1; + } + if (map[XY(snow[f].x, snow[f].y + 1)] == 0) { Plot(snow[f].x, snow[f].y, black); snow[f].y++; Plot(snow[f].x, snow[f].y, white); } - else if (map[XY(snow[f].x + 1, snow[f].y + 1)] == 0) + else if (map[XY(snow[f].x + dir, snow[f].y + 1)] == 0) { Plot(snow[f].x, snow[f].y, black); - snow[f].x++; + snow[f].x += dir; snow[f].y++; Plot(snow[f].x, snow[f].y, white); } - else if (map[XY(snow[f].x - 1, snow[f].y + 1)] == 0) + else if (map[XY(snow[f].x - dir, snow[f].y + 1)] == 0) { Plot(snow[f].x, snow[f].y, black); - snow[f].x--; + snow[f].x -= dir; snow[f].y++; Plot(snow[f].x, snow[f].y, white); } |