summaryrefslogtreecommitdiff
path: root/xd.c
diff options
context:
space:
mode:
Diffstat (limited to 'xd.c')
-rw-r--r--xd.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/xd.c b/xd.c
index 44a2ef0..703ca4f 100644
--- a/xd.c
+++ b/xd.c
@@ -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;
}
}