diff -u -r1.2 -r1.3 --- wl_agent.c 1 Dec 2001 13:01:05 -0000 1.2 +++ wl_agent.c 14 Dec 2001 00:48:30 -0000 1.3 @@ -158,10 +158,10 @@ // // side to side move +// note: here we'll let fall fixed strafe buttons into normal cursor movement +// so we'll be able to make circle movements (strafe + turning left/right) // - if (buttonstate[bt_strafe] || - buttonstate[bt_strafe_left] || - buttonstate[bt_strafe_right]) + if (buttonstate[bt_strafe]) { // // strafing @@ -184,9 +184,6 @@ } else { - // - // not strafing - // anglefrac += controlx; angleunits = anglefrac/ANGLESCALE; anglefrac -= angleunits*ANGLESCALE; @@ -199,6 +196,28 @@ } + // + // don't allow two strafes at same time + // + if ((buttonstate[bt_strafe_left] || buttonstate[bt_strafe_right]) && + !buttonstate[bt_strafe]) + { + if (strafe > 0) + { + angle = ob->angle - ANGLES/4; + if (angle < 0) + angle += ANGLES; + Thrust (angle,strafe*MOVESCALE); // move to left + } + else if (strafe < 0) + { + angle = ob->angle + ANGLES/4; + if (angle >= ANGLES) + angle -= ANGLES; + Thrust (angle,-strafe*MOVESCALE); // move to right + } + } + // // forward/backwards move // --- wl_def.h 1 Dec 2001 13:01:05 -0000 1.2 +++ wl_def.h 14 Dec 2001 00:48:30 -0000 1.3 @@ -872,7 +872,7 @@ // // curent user input // -extern int controlx,controly; // range from -100 to 100 +extern int controlx,controly,strafe; // range from -100 to 100 extern boolean buttonstate[NUMBUTTONS]; extern boolean demorecord,demoplayback; --- wl_play.c 7 Dec 2001 00:12:07 -0000 1.3 +++ wl_play.c 14 Dec 2001 00:48:30 -0000 1.4 @@ -66,7 +66,9 @@ // // curent user input // -int controlx,controly; // range from -100 to 100 per tic +int controlx, + controly, + strafe; // range from -100 to 100 per tic boolean buttonstate[NUMBUTTONS]; @@ -344,12 +346,16 @@ controly -= RUNMOVE*tics; if (Keyboard[dirscan[di_south]]) controly += RUNMOVE*tics; - if (Keyboard[dirscan[di_west]] || - buttonstate[bt_strafe_left]) + if (Keyboard[dirscan[di_west]]) controlx -= RUNMOVE*tics; - if (Keyboard[dirscan[di_east]] || - buttonstate[bt_strafe_right]) + if (Keyboard[dirscan[di_east]]) controlx += RUNMOVE*tics; + + // strafing with fixed keys + if (buttonstate[bt_strafe_left]) + strafe -= RUNMOVE*tics; + if (buttonstate[bt_strafe_right]) + strafe += RUNMOVE*tics; } else { @@ -357,12 +363,16 @@ controly -= BASEMOVE*tics; if (Keyboard[dirscan[di_south]]) controly += BASEMOVE*tics; - if (Keyboard[dirscan[di_west]] || - buttonstate[bt_strafe_left]) + if (Keyboard[dirscan[di_west]]) controlx -= BASEMOVE*tics; - if (Keyboard[dirscan[di_east]] || - buttonstate[bt_strafe_right]) + if (Keyboard[dirscan[di_east]]) controlx += BASEMOVE*tics; + + // strafing with fixed keys + if (buttonstate[bt_strafe_left]) + strafe -= BASEMOVE*tics; + if (buttonstate[bt_strafe_right]) + strafe += BASEMOVE*tics; } } @@ -449,6 +459,7 @@ = = controlx set between -100 and 100 per tic = controly += strafe = buttonheld[] the state of the buttons LAST frame = buttonstate[] the state of the buttons THIS frame = @@ -487,6 +498,7 @@ controlx = 0; controly = 0; + strafe = 0; memcpy (buttonheld,buttonstate,sizeof(buttonstate)); memset (buttonstate,0,sizeof(buttonstate)); @@ -552,6 +564,11 @@ else if (controly < min) controly = min; + if (strafe > max) + strafe = max; + else if (strafe < min) + strafe = min; + if (demorecord) { //