make a struct for squishy
this is horrid but should fix this speeding up when multiple players squish
This commit is contained in:
1 parent
37146b4c3d
commit
da0b714c92
2 files changed
+34
-22
No files matched your search
+11
-1
@@ -356,6 +356,16 @@ typedef enum
|
||||
LAP__MAX
|
||||
} laptime_e;
|
||||
|
||||
// yes i made a whole struct for this :chonkbuncle:
|
||||
typedef struct squishdance_s
|
||||
{
|
||||
tic_t countdown; // hold "custom 3" for 2 seconds to engange le dance
|
||||
tic_t time;
|
||||
fixed_t work;
|
||||
fixed_t ang;
|
||||
fixed_t bounce; // hehe squishy
|
||||
} squishdance_t;
|
||||
|
||||
// ========================================================================
|
||||
// PLAYER STRUCTURE
|
||||
// ========================================================================
|
||||
@@ -556,7 +566,7 @@ typedef struct player_s
|
||||
|
||||
fixed_t spinoutrot; // When a player spins out, this value increments modulus 360.
|
||||
|
||||
tic_t dancetime;
|
||||
squishdance_t squishdance;
|
||||
|
||||
fixed_t fovadd; // adjust FOV for hw rendering
|
||||
} player_t;
|
||||
|
||||
+23
-21
@@ -4436,40 +4436,39 @@ DoABarrelRoll (player_t *player)
|
||||
player->tilt = slope;
|
||||
}
|
||||
|
||||
#define SPINOUTROTSPEED (24 * FRACUNIT)
|
||||
#define MAXSPINROT (360 * FRACUNIT)
|
||||
|
||||
static void P_DoFunnyDance (player_t *player)
|
||||
// mhhm this is definitely not mostly copy pasted code from SRB2s music test (:
|
||||
// TODO: make this sane lmao
|
||||
static void P_DoFunnyDance(player_t *player)
|
||||
{
|
||||
static tic_t time = 0;
|
||||
fixed_t bounce;
|
||||
fixed_t work, bpm;
|
||||
angle_t ang;
|
||||
fixed_t bpm;
|
||||
|
||||
if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop
|
||||
return;
|
||||
|
||||
bounce = 0;
|
||||
player->squishdance.bounce = 0;
|
||||
|
||||
// bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection
|
||||
bpm = FixedDiv((60*TICRATE)<<FRACBITS, 9175040); // 140bpm ish
|
||||
|
||||
work = (time << FRACBITS) % bpm;
|
||||
player->squishdance.work = (player->squishdance.time << FRACBITS) % bpm;
|
||||
|
||||
if (time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes
|
||||
time = (work>>FRACBITS);
|
||||
if (player->squishdance.time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes
|
||||
player->squishdance.time = (player->squishdance.work>>FRACBITS);
|
||||
|
||||
work = FixedDiv(work*180, bpm);
|
||||
player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm);
|
||||
|
||||
ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK;
|
||||
bounce = (FINESINE(ang) - FRACUNIT/2);
|
||||
player->squishdance.ang = ((FixedAngle(player->squishdance.work)>>ANGLETOFINESHIFT) & FINEMASK);
|
||||
player->squishdance.bounce = (FINESINE(player->squishdance.ang) - FRACUNIT/2);
|
||||
|
||||
player->mo->spritexscale -= bounce/2;
|
||||
player->mo->spriteyscale += bounce/2;
|
||||
player->mo->spritexscale -= player->squishdance.bounce/2;
|
||||
player->mo->spriteyscale += player->squishdance.bounce/2;
|
||||
|
||||
time++; // bruh
|
||||
player->squishdance.time++;
|
||||
}
|
||||
|
||||
#define SPINOUTROTSPEED (24 * FRACUNIT)
|
||||
#define MAXSPINROT (360 * FRACUNIT)
|
||||
|
||||
//
|
||||
// P_PlayerThink
|
||||
//
|
||||
@@ -5009,13 +5008,16 @@ void P_PlayerThink(player_t *player)
|
||||
|
||||
if (cmd->buttons & BT_CUSTOM3)
|
||||
{
|
||||
player->dancetime++;
|
||||
player->squishdance.countdown++;
|
||||
|
||||
if (player->dancetime > TICRATE*2)
|
||||
if (player->squishdance.countdown > TICRATE*2)
|
||||
P_DoFunnyDance(player);
|
||||
}
|
||||
else
|
||||
player->dancetime = 0;
|
||||
{
|
||||
player->squishdance.countdown = 0;
|
||||
player->squishdance.time = 0;
|
||||
}
|
||||
|
||||
// Flash player after being hit.
|
||||
if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should.
|
||||
|
||||
Reference in new issue
Block a user