mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Shift camera sideways toward player angle
This commit is contained in:
parent
c272cf5ecb
commit
eaef39c974
5 changed files with 37 additions and 9 deletions
|
|
@ -826,6 +826,8 @@ void D_RegisterClientCommands(void)
|
||||||
// hi here's some new controls
|
// hi here's some new controls
|
||||||
CV_RegisterVar(&cv_abilitydirection[0]);
|
CV_RegisterVar(&cv_abilitydirection[0]);
|
||||||
CV_RegisterVar(&cv_abilitydirection[1]);
|
CV_RegisterVar(&cv_abilitydirection[1]);
|
||||||
|
CV_RegisterVar(&cv_cam_shiftfacing[0]);
|
||||||
|
CV_RegisterVar(&cv_cam_shiftfacing[1]);
|
||||||
CV_RegisterVar(&cv_cam_turnfacing[0]);
|
CV_RegisterVar(&cv_cam_turnfacing[0]);
|
||||||
CV_RegisterVar(&cv_cam_turnfacing[1]);
|
CV_RegisterVar(&cv_cam_turnfacing[1]);
|
||||||
CV_RegisterVar(&cv_cam_turnfacingability[0]);
|
CV_RegisterVar(&cv_cam_turnfacingability[0]);
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,10 @@ consvar_t cv_abilitydirection[2] = {
|
||||||
{"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
{"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||||
};
|
};
|
||||||
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
|
||||||
|
consvar_t cv_cam_shiftfacing[2] = {
|
||||||
|
{"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||||
|
{"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||||
|
};
|
||||||
consvar_t cv_cam_turnfacing[2] = {
|
consvar_t cv_cam_turnfacing[2] = {
|
||||||
{"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
{"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||||
{"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
{"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis
|
||||||
extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest;
|
extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest;
|
||||||
|
|
||||||
// hi here's some new controls
|
// hi here's some new controls
|
||||||
extern consvar_t cv_abilitydirection[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2];
|
extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2];
|
||||||
|
|
||||||
// mouseaiming (looking up/down with the mouse or keyboard)
|
// mouseaiming (looking up/down with the mouse or keyboard)
|
||||||
#define KB_LOOKSPEED (1<<25)
|
#define KB_LOOKSPEED (1<<25)
|
||||||
|
|
|
||||||
14
src/m_menu.c
14
src/m_menu.c
|
|
@ -1182,9 +1182,10 @@ static menuitem_t OP_CameraOptionsMenu[] =
|
||||||
{IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70},
|
{IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80},
|
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 100},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[0], 100},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 110},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 110},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 120},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 120},
|
||||||
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 130},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 140},
|
{IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 140},
|
||||||
};
|
};
|
||||||
|
|
@ -1200,9 +1201,10 @@ static menuitem_t OP_Camera2OptionsMenu[] =
|
||||||
{IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70},
|
{IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80},
|
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 100},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 100},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 110},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 110},
|
||||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 120},
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 120},
|
||||||
|
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 130},
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 140},
|
{IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 140},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
24
src/p_user.c
24
src/p_user.c
|
|
@ -9677,6 +9677,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
subsector_t *newsubsec;
|
subsector_t *newsubsec;
|
||||||
fixed_t f1, f2;
|
fixed_t f1, f2;
|
||||||
|
|
||||||
|
static fixed_t camsideshift[2] = {0, 0};
|
||||||
|
fixed_t shiftx = 0, shifty = 0;
|
||||||
|
|
||||||
// We probably shouldn't move the camera if there is no player or player mobj somehow
|
// We probably shouldn't move the camera if there is no player or player mobj somehow
|
||||||
if (!player || !player->mo)
|
if (!player || !player->mo)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -9882,6 +9885,20 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cv_abilitydirection[(thiscam == &camera) ? 0 : 1].value)
|
||||||
|
{
|
||||||
|
// Shift the camera slightly to the sides depending on the player facing direction
|
||||||
|
UINT8 forplayer = (thiscam == &camera) ? 0 : 1;
|
||||||
|
fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value);
|
||||||
|
|
||||||
|
shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3));
|
||||||
|
camsideshift[forplayer] = shift;
|
||||||
|
|
||||||
|
shift = FixedMul(shift, camdist);
|
||||||
|
shiftx = -FixedMul(FINESINE(angle>>ANGLETOFINESHIFT), shift);
|
||||||
|
shifty = FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT), shift);
|
||||||
|
}
|
||||||
|
|
||||||
// sets ideal cam pos
|
// sets ideal cam pos
|
||||||
if (twodlevel || (mo->flags2 & MF2_TWOD))
|
if (twodlevel || (mo->flags2 & MF2_TWOD))
|
||||||
dist = 480<<FRACBITS;
|
dist = 480<<FRACBITS;
|
||||||
|
|
@ -10228,8 +10245,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
viewpointx = mo->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
viewpointx = mo->x + shiftx + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
||||||
viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
viewpointy = mo->y + shifty + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!camstill && !resetcalled && !paused)
|
if (!camstill && !resetcalled && !paused)
|
||||||
|
|
@ -10270,6 +10287,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
thiscam->momz = FixedMul(z - thiscam->z, camspeed);
|
thiscam->momz = FixedMul(z - thiscam->z, camspeed);
|
||||||
|
|
||||||
|
thiscam->momx += FixedMul(shiftx, camspeed);
|
||||||
|
thiscam->momy += FixedMul(shifty, camspeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute aming to look the viewed point
|
// compute aming to look the viewed point
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue