summaryrefslogtreecommitdiff
path: root/xd.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-10-25 06:56:08 +0000
committerIan C <ianc@noddybox.co.uk>2018-10-25 06:56:08 +0000
commit326b09773ae658e0848f4171172bbae4c600e5ca (patch)
tree7600a4bdb777f63783f086cfeb975206d5093acb /xd.c
parente7f93ab55aabf5040755b7626df97f1151f9dd29 (diff)
Added mouse look to road demo.
Diffstat (limited to 'xd.c')
-rw-r--r--xd.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/xd.c b/xd.c
index 703ca4f..29419fb 100644
--- a/xd.c
+++ b/xd.c
@@ -281,7 +281,7 @@ static DemoInfo demotbl[NO_DEMOS]=
UsesPixmap
},
{
- "Road Demo (LMB toggle culling)",
+ "Road Demo (LMB toggle culling, RMB toggle mouselook)",
RoadDemo,
UsesPixmap
},
@@ -4333,6 +4333,7 @@ static void RoadDemo(void)
static double dxi, dyi;
static int dcount;
static int cull = TRUE;
+ static int mouselook = FALSE;
int f,r;
double x, y, z;
@@ -4415,6 +4416,17 @@ static void RoadDemo(void)
}
}
+ if (mouse_b&Button3Mask)
+ {
+ static time_t bounce=0;
+
+ if (bounce!=time(NULL))
+ {
+ mouselook = !mouselook;
+ bounce=time(NULL);
+ }
+ }
+
Cls();
x = -ROAD_WIDTH / 2;
@@ -4422,35 +4434,43 @@ static void RoadDemo(void)
z = 10.0;
max_y = height;
- ang_x = atan(fabs(road[0].dy) / ROAD_Z_INC);
-
- if (isnan(ang_x))
+ if (mouselook)
{
- ang_x = 0;
+ ang_y = -(mouse_x - centre_x);
+ ang_x = mouse_y - centre_y;
}
else
{
- ang_x = DEG(ang_x) * 10.0;
+ ang_x = atan(fabs(road[0].dy) / ROAD_Z_INC);
- if (road[0].dy > 0)
+ if (isnan(ang_x))
{
- ang_x = -ang_x;
+ ang_x = 0;
}
- }
+ else
+ {
+ ang_x = DEG(ang_x) * 10.0;
- ang_y = atan(fabs(road[0].dx) / ROAD_Z_INC);
+ if (road[0].dy > 0)
+ {
+ ang_x = -ang_x;
+ }
+ }
- if (isnan(ang_y))
- {
- ang_y = 0;
- }
- else
- {
- ang_y = DEG(ang_y) * 10.0;
+ ang_y = atan(fabs(road[0].dx) / ROAD_Z_INC);
- if (road[0].dx > 0)
+ if (isnan(ang_y))
{
- ang_y = -ang_y;
+ ang_y = 0;
+ }
+ else
+ {
+ ang_y = DEG(ang_y) * 10.0;
+
+ if (road[0].dx > 0)
+ {
+ ang_y = -ang_y;
+ }
}
}