diff options
author | Ian C <ianc@noddybox.co.uk> | 2018-10-24 08:59:10 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2018-10-24 08:59:10 +0000 |
commit | e7f93ab55aabf5040755b7626df97f1151f9dd29 (patch) | |
tree | e1ecbeb5170f6aa5b6537f997343a32f8e59febf /xd.c | |
parent | 8b08533e3536d08d3d733aa424069f9a8d10300c (diff) |
Tweaks to road demo.
Diffstat (limited to 'xd.c')
-rw-r--r-- | xd.c | 52 |
1 files changed, 38 insertions, 14 deletions
@@ -281,7 +281,7 @@ static DemoInfo demotbl[NO_DEMOS]= UsesPixmap }, { - "Road Demo", + "Road Demo (LMB toggle culling)", RoadDemo, UsesPixmap }, @@ -4332,6 +4332,7 @@ static void RoadDemo(void) static double dx, dy; static double dxi, dyi; static int dcount; + static int cull = TRUE; int f,r; double x, y, z; @@ -4349,7 +4350,7 @@ static void RoadDemo(void) { if (dcount == 0 && dx == 0 && dy == 0) { - dcount = RND2(20, 500); + dcount = RND2(200, 500); dx = 0; dy = 0; dxi = RND(10) / 40.0 - 0.125; @@ -4376,17 +4377,23 @@ static void RoadDemo(void) double sdx = SgnF(dx); double sdy = SgnF(dy); - dx -= dxi; - dy -= dyi; + if (dx != 0.0) + { + dx -= dxi; + } + + if (dy != 0.0) + { + dy -= dyi; + } if (SgnF(dx) != sdx) { dx = 0; - dy = 0; } - else if (SgnF(dy) != sdy) + + if (SgnF(dy) != sdy) { - dx = 0; dy = 0; } } @@ -4397,6 +4404,17 @@ static void RoadDemo(void) } } + if (mouse_b&Button1Mask) + { + static time_t bounce=0; + + if (bounce!=time(NULL)) + { + cull = !cull; + bounce=time(NULL); + } + } + Cls(); x = -ROAD_WIDTH / 2; @@ -4449,7 +4467,7 @@ static void RoadDemo(void) if (Project(rx2, ry2, rz2, &xp)) { - if (xp.y < max_y) + if (!cull || xp.y < max_y) { Plot(xp.x, xp.y, white); @@ -4468,7 +4486,7 @@ static void RoadDemo(void) { if (dcount == 0 && dx == 0 && dy == 0) { - dcount = RND2(20, 500); + dcount = RND2(200, 500); dx = 0; dy = 0; dxi = RND(10) / 40.0 - 0.125; @@ -4495,17 +4513,23 @@ static void RoadDemo(void) double sdx = SgnF(dx); double sdy = SgnF(dy); - dx -= dxi; - dy -= dyi; + if (dx != 0.0) + { + dx -= dxi; + } + + if (dy != 0.0) + { + dy -= dyi; + } if (SgnF(dx) != sdx) { dx = 0; - dy = 0; } - else if (SgnF(dy) != sdy) + + if (SgnF(dy) != sdy) { - dx = 0; dy = 0; } } |