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);
|
Particle::spew(this);
|
||||||
|
|
||||||
auto oldScale = scale();
|
|
||||||
scale(3*scale()/2);
|
scale(3*scale()/2);
|
||||||
|
|
||||||
if(hasCustomHusk){
|
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
|
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
|
||||||
|
fixed_t huskScale = FixedDiv(mapobjectscale, scale());
|
||||||
//approximate inverse spritescale() by exaggerating fixed_t values by 100 and then dividing back down instead of doing float maths
|
spritexscale(FixedMul(spritexscale(), huskScale));
|
||||||
//this way there's no decimal points and no potential for desyncs across builds/platforms
|
spriteyscale(FixedMul(spriteyscale(), huskScale));
|
||||||
//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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
health = 1;
|
health = 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue