Skip to content

Commit 59c42ce

Browse files
committed
Better shadow rotation
1 parent 12f199f commit 59c42ce

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/progressed/entities/bullet/pseudo3d/ArcBasicBulletType.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import arc.*;
44
import arc.graphics.g2d.*;
55
import arc.math.*;
6+
import arc.util.*;
67
import mindustry.gen.*;
78
import progressed.graphics.*;
89

@@ -52,11 +53,20 @@ public void draw(Bullet b){
5253
float scl = shadowScale(data.z),
5354
sX = Angles.trnsx(225f, data.z) + b.x,
5455
sY = Angles.trnsy(225f, data.z) + b.y,
55-
sRot = Angles.angle(b.originX, b.originY, b.aimX, b.aimY), //TODO better shadow rotation calculation
56+
sRot = Angles.angle(b.originX, b.originY, b.aimX, b.aimY),
5657
sAlpha = Draw3D.shadowAlpha(data.z);
58+
59+
float pitch = Tmp.v1.set(b.vel.len(), data.zVel).angle(); //0 - 90 or 270-360
60+
if(pitch <= 90){ //Going vertical, aim away from current point.
61+
sRot = Mathf.lerp(sRot, sRot < 45f ? -135f : 225f, pitch / 90f);
62+
}else if(pitch >= 270f){ //Falling down, aim towards current point.
63+
sRot = Mathf.lerp(sRot, sRot > 225f ? 405f : 45f, (360f - pitch) / 90f);
64+
}
65+
float fsRot = sRot; //I love Java
66+
5767
Draw3D.shadow(() -> {
5868
Draw.scl(scl);
59-
PMDrawf.shadow(region, sX, sY, sRot, sAlpha);
69+
PMDrawf.shadow(region, sX, sY, fsRot, sAlpha);
6070
Draw.scl();
6171
});
6272
}

0 commit comments

Comments
 (0)