mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
With the help of GitLab user Lach, I turned my approximated sprite scaling in destroyed-kart.cpp into 100% accurate sprite scaling
This commit is contained in:
parent
40b231ff62
commit
2bdc014006
1 changed files with 3 additions and 10 deletions
|
@ -326,20 +326,13 @@ struct Kart : Mobj
|
|||
}
|
||||
|
||||
Particle::spew(this);
|
||||
|
||||
auto oldScale = scale();
|
||||
scale(3*scale()/2);
|
||||
|
||||
if(hasCustomHusk){
|
||||
flags |= MF_NOSQUISH; //K_Squish() automates spritexscale/spriteyscale & this flag prevents that at the cost of no squish visual when the kart husk hits the ground
|
||||
|
||||
//approximate inverse spritescale() by exaggerating fixed_t values by 100 and then dividing back down instead of doing float maths
|
||||
//this way there's no decimal points and no potential for desyncs across builds/platforms
|
||||
//there is potential this could overflow at exceptionally high scale() values
|
||||
fixed_t z = FixedDiv(FixedMul(scale(),100),oldScale);
|
||||
auto formula = [&](fixed_t subject){return FixedDiv(FixedMul(subject,100),z);};
|
||||
spritexscale(formula(spritexscale()));
|
||||
spriteyscale(formula(spriteyscale()));
|
||||
fixed_t huskScale = FixedDiv(mapobjectscale, scale());
|
||||
spritexscale(FixedMul(spritexscale(), huskScale));
|
||||
spriteyscale(FixedMul(spriteyscale(), huskScale));
|
||||
}
|
||||
|
||||
health = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue