Fix effects in splitscreen

This commit is contained in:
Latapostrophe 2021-04-24 14:46:39 +02:00
parent e980be69ef
commit d253b66524
4 changed files with 56 additions and 32 deletions

View file

@ -684,6 +684,9 @@ INT32 ITEM2_X, ITEM2_Y;
INT32 LAPS2_X, LAPS2_Y;
INT32 POSI2_X, POSI2_Y;
// trick "cool"
INT32 TCOOL_X, TCOOL_Y;
void K_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 dupy)
{
@ -987,6 +990,10 @@ static void K_initKartHUD(void)
WANT_X = BASEVIDWIDTH - 55; // 270
WANT_Y = BASEVIDHEIGHT- 71; // 176
// trick COOL
TCOOL_X = (BASEVIDWIDTH)/2;
TCOOL_Y = (BASEVIDHEIGHT)/2 -10;
if (r_splitscreen) // Splitscreen
{
ITEM_X = 5;
@ -1029,6 +1036,8 @@ static void K_initKartHUD(void)
MINI_X = (3*BASEVIDWIDTH/4);
MINI_Y = (3*BASEVIDHEIGHT/4);
TCOOL_X = (BASEVIDWIDTH)/4;
if (r_splitscreen > 2) // 4P-only
{
MINI_X = (BASEVIDWIDTH/2);
@ -3962,40 +3971,23 @@ static fixed_t stretch[6][2] = {
{FRACUNIT/4, FRACUNIT*4},
{FRACUNIT/2, FRACUNIT*2},
{FRACUNIT, FRACUNIT},
{FRACUNIT*2, FRACUNIT/2},
{FRACUNIT*4, FRACUNIT/4},
{FRACUNIT*2, FRACUNIT/2},
{FRACUNIT*4, FRACUNIT/2},
{FRACUNIT*8, FRACUNIT/4},
{FRACUNIT*4, FRACUNIT/2},
};
static void K_drawTrickCool(void)
{
tic_t timer = TICRATE - stplyr->karthud[khud_trickcool];
INT32 x = (BASEVIDWIDTH/2);
INT32 y = ((BASEVIDHEIGHT)/2)-10;
// @TODO: fix this shit
/*if (r_splitscreen > 2) // 4p split
{
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]])
{
x /= 2;
y /= 2;
}
else
{
x /= 2 + BASEVIDWIDTH/2;
y /= 2 + BASEVIDHEIGHT/2;
}
}*/
if (timer <= 6)
{
V_DrawStretchyFixedPatch(x<<FRACBITS, y<<FRACBITS, stretch[timer-1][0], stretch[timer-1][1], V_HUDTRANS, kp_trickcool[splitscreen ? 1 : 0], NULL);
V_DrawStretchyFixedPatch(TCOOL_X<<FRACBITS, TCOOL_Y<<FRACBITS, stretch[timer-1][0], stretch[timer-1][1], V_HUDTRANS|V_SPLITSCREEN, kp_trickcool[splitscreen ? 1 : 0], NULL);
}
else if (leveltime & 1)
{
V_DrawFixedPatch(x<<FRACBITS, (y<<FRACBITS) - (timer-10)*FRACUNIT/2, FRACUNIT, V_HUDTRANS, kp_trickcool[splitscreen ? 1 : 0], NULL);
V_DrawFixedPatch(TCOOL_X<<FRACBITS, (TCOOL_Y<<FRACBITS) - (timer-10)*FRACUNIT/2, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_trickcool[splitscreen ? 1 : 0], NULL);
}
}

View file

@ -8145,8 +8145,6 @@ void K_AdjustPlayerFriction(player_t *player)
// if you tumble, they'll fall off instead.
//
// @TODO: R_PointToAngle is unreliable in splitscreen..............
#define RADIUSSCALING 6
#define MINRADIUS 12
@ -8156,18 +8154,15 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz)
fixed_t pos, tx, ty, tz;
mobj_t *flame;
angle_t hang = R_PointToAngle(player->mo->x, player->mo->y) + ANG1*90; // horizontal angle
angle_t vang = -FixedAngle(momz)*12 + (ANG1*45); // vertical angle... arbitrary rotation speed for now.
fixed_t dist = FixedMul(max(MINRADIUS<<FRACBITS, abs(momz)*RADIUSSCALING), player->mo->scale); // distance.
angle_t hang = R_PointToAnglePlayer(player, player->mo->x, player->mo->y) + ANG1*90; // horizontal angle
angle_t vang = -FixedAngle(momz)*12 + (ANG1*45); // vertical angle dependant on momz, we want it to line up at 45 degrees at the perfect frame to trick at
fixed_t dist = FixedMul(max(MINRADIUS<<FRACBITS, abs(momz)*RADIUSSCALING), player->mo->scale); // distance.
UINT8 i;
//CONS_Printf("a\n");
// Do you like trig? cool, me neither.
for (i=0; i < 2; i++)
{
//CONS_Printf("%d\n", i);
pos = FixedMul(dist, FINESINE(vang>>ANGLETOFINESHIFT));
tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT));
ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT));
@ -8190,7 +8185,8 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz)
if (player->trickpanel > 1) // we tricked
{
// Send the thing outwards via ghetto maths
// Send the thing outwards via ghetto maths which involves redoing the whole 3d sphere again, witht the "vertical" angle shifted by 90 degrees.
// There's probably a simplier way to do this the way I want to but this works.
pos = FixedMul(48*player->mo->scale, FINESINE((vang +ANG1*90)>>ANGLETOFINESHIFT));
tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT));
ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT));
@ -8200,7 +8196,7 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz)
flame->momy = ty -player->mo->y;
flame->momz = tz -(player->mo->z+player->mo->height/2);
}
else // we failed the trick.
else // we failed the trick, drop the half circles, it'll be funny I promise.
{
flame->flags &= ~MF_NOGRAVITY;
P_SetObjectMomZ(flame, 4<<FRACBITS, false);

View file

@ -332,6 +332,41 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y)
0;
}
// Similar to R_PointToAngle, but requires an additional player_t argument.
// If this player is a local displayplayer, this will base off the calculations off of their camera instead, otherwise use viewx/viewy as usual.
// Yes this is kinda ghetto.
angle_t R_PointToAnglePlayer(player_t *player, fixed_t x, fixed_t y)
{
fixed_t refx = viewx, refy = viewy;
camera_t *cam = &camera[0];
// Check for splitscreen players and get their cam if possible.
if (player == &players[displayplayers[1]])
cam = &camera[1];
else if (player == &players[displayplayers[2]])
cam = &camera[2];
else if (player == &players[displayplayers[3]])
cam = &camera[3];
// use whatever cam we found's coordinates.
refx = cam->x;
refy = cam->y;
// Now do whatever tehe fuck is this hellish maths from R_PointToAngle while swapping viewx/viewy for our refx/refy
return (y -= refy, (x -= refx) || y) ?
x >= 0 ?
y >= 0 ?
(x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0
ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1
x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8
ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7
y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3
ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2
(x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4
ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5
0;
}
// This version uses 64-bit variables to avoid overflows with large values.
// Currently used only by OpenGL rendering.
angle_t R_PointToAngle64(INT64 x, INT64 y)

View file

@ -63,6 +63,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node);
INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line);
angle_t R_PointToAngle(fixed_t x, fixed_t y);
angle_t R_PointToAnglePlayer(player_t *player, fixed_t x, fixed_t y);
angle_t R_PointToAngle64(INT64 x, INT64 y);
angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1);