diff options
-rw-r--r-- | xd.c | 79 |
1 files changed, 71 insertions, 8 deletions
@@ -262,7 +262,7 @@ static DemoInfo demotbl[NO_DEMOS]= UsesPixmap }, { - "Catwalk trench (RMB to change draw mode)", + "Catwalk trench (LMB to toggle bounce. RMB to change draw mode)", CatwalkDemo, UsesPixmap }, @@ -3771,7 +3771,7 @@ static void FollowDemo(void) #define TRENCH_X 300 #define TRENCH_Y_TOP -200 #define TRENCH_Y_BOT 100 -#define TRENCH_Z_MAX 10000 +#define TRENCH_Z_MAX 20000 #define TRENCH_Z_MIN 10 #define TRENCH_CWH 50 @@ -3779,7 +3779,7 @@ static void CatwalkDemo(void) { static const int speed=5; - static unsigned long col[2]; + static unsigned long col[3]; static Point3D trench_point[8] = { @@ -3821,7 +3821,7 @@ static void CatwalkDemo(void) {8,3,{0,0,0},trench_point,trench_poly,trench_work_3d,trench_work_xp, 0,0,0,MODE_WIRE,-1,True}; - static const int no_catwalk = 5; + static const int no_catwalk = 10; static Obj3D *catwalk; @@ -3829,14 +3829,23 @@ static void CatwalkDemo(void) static int init=FALSE; + static int move = FALSE; + + static int move_y = 0; + static int move_yi = 0; + + static int *catwalk_y; + int f,r; if (!init) { col[0]=GetCol(255, 255, 255); col[1]=GetCol(255, 255, 0); + col[2]=GetCol(0, 0, 0); catwalk = Grab(sizeof *catwalk * no_catwalk); + catwalk_y = Grab(sizeof *catwalk_y * no_catwalk); for(f = 0; f < no_catwalk; f++) { @@ -3844,8 +3853,8 @@ static void CatwalkDemo(void) catwalk[f].no_poly = 1; catwalk[f].origin.x = 0; - catwalk[f].origin.y = RND2(TRENCH_Y_BOT - TRENCH_CWH, - TRENCH_Y_TOP + TRENCH_CWH); + catwalk_y[f] = RND2(TRENCH_Y_BOT - TRENCH_CWH, + TRENCH_Y_TOP + TRENCH_CWH); catwalk[f].origin.z = TRENCH_Z_MAX - 1500 * f; catwalk[f].ps = cw_point; @@ -3868,6 +3877,29 @@ static void CatwalkDemo(void) init=TRUE; } + if (mouse_b&Button1Mask) + { + static time_t bounce=0; + + if (bounce!=time(NULL)) + { + move = !move; + + if (move) + { + move_y = 0; + move_yi = 1; + } + else + { + move_y = 0; + move_yi = 0; + } + + bounce=time(NULL); + } + } + if (mouse_b&Button3Mask) { static time_t bounce=0; @@ -3907,10 +3939,32 @@ static void CatwalkDemo(void) Cls(); + trench.origin.y = move_y; + DrawObj(&trench,col); + if (drawmode == MODE_SOLID) + { + trench.mode = MODE_WIRE; + + for(f = 0; f < 3; f++) + { + trench.poly[f].col = 2; + } + + DrawObj(&trench,col); + + trench.mode = MODE_SOLID; + + for(f = 0; f < 3; f++) + { + trench.poly[f].col = 0; + } + } + for(f = 0; f < no_catwalk; f++) { + catwalk[f].origin.y = catwalk_y[f] + move_y; DrawObj(catwalk + f,col); catwalk[f].origin.z -= speed; @@ -3923,13 +3977,22 @@ static void CatwalkDemo(void) for(f = no_catwalk-2; f >= 0; f--) { catwalk[f+1] = catwalk[f]; + catwalk_y[f + 1] = catwalk_y[f]; } catwalk[0] = t; catwalk[0].origin.z = TRENCH_Z_MAX; - catwalk[0].origin.y = RND2(TRENCH_Y_BOT - TRENCH_CWH, - TRENCH_Y_TOP + TRENCH_CWH); + catwalk_y[0] = RND2(TRENCH_Y_BOT - TRENCH_CWH, + TRENCH_Y_TOP + TRENCH_CWH); + } + + move_y += move_yi; + + if (move_y >= 200 || move_y <= -90) + { + move_yi = -move_yi; + move_y += move_yi; } } |