summaryrefslogtreecommitdiff
path: root/xd.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-10-26 06:40:23 +0000
committerIan C <ianc@noddybox.co.uk>2018-10-26 06:40:23 +0000
commitf90feaa36da1f1b456cb1e92fd2f13d6a9abd5e0 (patch)
treef431470f9766dadafc878f0c80199f85a77f2510 /xd.c
parentb38b27007edc9d5f012c4fd124646c5043a71a2d (diff)
Added some extra randomness to the snow demo.
Diffstat (limited to 'xd.c')
-rw-r--r--xd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/xd.c b/xd.c
index e682773..ba8b4fe 100644
--- a/xd.c
+++ b/xd.c
@@ -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);
}