Skip to content

Commit 8ea0245

Browse files
committed
New charge effect
1 parent 96255d4 commit 8ea0245

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

src/progressed/content/bullets/PMBullets.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import arc.graphics.*;
44
import mindustry.content.*;
55
import mindustry.entities.bullet.*;
6+
import mindustry.entities.effect.*;
67
import mindustry.gen.*;
78
import mindustry.graphics.*;
89
import progressed.content.*;
@@ -11,6 +12,7 @@
1112
import progressed.entities.bullet.energy.*;
1213
import progressed.entities.bullet.physical.*;
1314
import progressed.entities.bullet.unit.*;
15+
import progressed.entities.effect.*;
1416

1517
public class PMBullets{
1618
public static BulletType
@@ -110,7 +112,13 @@ public static void load(){
110112
backMove = false;
111113
lightRadius = 8f;
112114
lightOpacity = 0.7f;
113-
chargeEffect = EnergyFx.kugelblitzGrow;
115+
int times = 25;
116+
float life = EnergyFx.kugelblitzGrow.lifetime;
117+
chargeEffect = new MultiEffect(
118+
new WrapEffect(new RepeatEffect(EnergyFx.kugelblitzCharge, (life - EnergyFx.kugelblitzCharge.lifetime - 1f) / times, times), Color.black, 48f),
119+
EnergyFx.kugelblitzGrow
120+
);
121+
chargeEffect.lifetime = life;
114122
}};
115123

116124
excaliburLaser = new CrossLaserBulletType(1500f){{

src/progressed/content/effects/EnergyFx.java

+20-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import mindustry.entities.*;
88
import mindustry.graphics.*;
99
import progressed.graphics.*;
10-
import progressed.graphics.renders.*;
10+
import progressed.util.*;
1111

1212
import static arc.graphics.g2d.Draw.*;
1313
import static arc.graphics.g2d.Lines.*;
@@ -57,24 +57,34 @@ public class EnergyFx{
5757
}),
5858

5959
kugelblitzGrow = new Effect(80f, e -> {
60-
float in = 6f, out = 160f;
61-
float fin = e.fin(Interp.sineOut);
62-
PMRenders.blackHole(e.x, e.y, in * fin, out / 2f * fin, e.color);
60+
int sides = 20 * 4;
61+
float space = 360f / sides;
62+
float fin = e.fin(Interp.circleOut);
63+
float rX = 20 * fin, rY = 10 * fin;
64+
float in = Color.whiteFloatBits, out = e.color.toFloatBits();
65+
66+
for(int i = 0; i < sides; i++){
67+
float t1 = i * space, t2 = (i + 1) * space;
68+
Tmp.v1.trns(t1, PMMathf.circleStarPoint(t1)).scl(rX, rY).add(e.x, e.y);
69+
Tmp.v2.trns(t2, PMMathf.circleStarPoint(t2)).scl(rX, rY).add(e.x, e.y);
70+
Fill.quad(
71+
e.x, e.y, in,
72+
e.x, e.y, in,
73+
Tmp.v1.x, Tmp.v1.y, out,
74+
Tmp.v2.x, Tmp.v2.y, out
75+
);
76+
}
6377
}),
6478

79+
kugelblitzCharge = makeSwirlEffect(30f, 8, 2f, 15f, 90f, false).layer(Layer.bullet - 0.03f),
80+
6581
blackHoleSwirl = makeSwirlEffect(90f, 8, 3f, 90f, 720f, true).layer(Layer.effect + 0.005f),
6682

6783
blackHoleDespawn = new Effect(40f, e -> {
6884
Lines.stroke(2f * e.fout(), Color.black);
6985
Lines.circle(e.x, e.y, 18f * e.fin(Interp.pow3Out));
7086
}).layer(Layer.effect + 0.03f),
7187

72-
blackHoleAbsorb = new Effect(20f, e -> {
73-
color(Color.black);
74-
stroke(2f * e.fout(Interp.pow3In));
75-
Lines.circle(e.x, e.y, 8f * e.fout(Interp.pow3In));
76-
}),
77-
7888
sentinelBlast = new Effect(80f, 150f, e -> {
7989
color(Pal.missileYellow);
8090

src/progressed/entities/bullet/energy/BlackHoleBulletType.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ public class BlackHoleBulletType extends BulletType{
2727
);
2828

2929
public Color color = Color.black;
30-
public Effect absorbEffect = EnergyFx.blackHoleAbsorb, swirlEffect = EnergyFx.blackHoleSwirl;
30+
public Effect swirlEffect = EnergyFx.blackHoleSwirl;
3131
public float suctionRadius = 160f, size = 6f, lensEdge = -1f, damageRadius = 17f;
3232
public float force = 10f, scaledForce = 800f, bulletForce = 0.1f, bulletScaledForce = 1f;
3333
public float bulletDamage = 10f;
34+
public float growTime = 10f, shrinkTime = -1f;
3435
public float swirlInterval = 3f;
3536
public int swirlEffects = 4;
3637
public boolean repel;
@@ -49,6 +50,7 @@ public BlackHoleBulletType(float speed, float damage){
4950
public void init(){
5051
super.init();
5152
if(lensEdge < 0f) lensEdge = suctionRadius / 2f;
53+
if(shrinkTime < 0f) shrinkTime = swirlEffect.lifetime;
5254

5355
drawSize = Math.max(drawSize, lensEdge * 2f);
5456
}
@@ -105,9 +107,8 @@ public void updateTrailEffects(Bullet b){
105107

106108
if(swirlInterval > 0f && b.time <= b.lifetime - swirlEffect.lifetime){
107109
if(b.timer(0, swirlInterval)){
108-
int sign = Mathf.sign(Mathf.randomSeed(b.id, -1, 0));
109110
for(int i = 0; i < swirlEffects; i++){
110-
swirlEffect.at(b.x, b.y, suctionRadius * sign, b.team.color, b);
111+
swirlEffect.at(b.x, b.y, suctionRadius, b.team.color, b);
111112
}
112113
}
113114
}
@@ -125,7 +126,10 @@ public void drawLight(Bullet b){
125126
}
126127

127128
public float fout(Bullet b){
128-
return Interp.sineOut.apply(1 - Mathf.curve(b.time, b.lifetime - swirlEffect.lifetime, b.lifetime));
129+
return Interp.sineOut.apply(
130+
Mathf.curve(b.time, 0f, growTime)
131+
- Mathf.curve(b.time, b.lifetime - shrinkTime, b.lifetime)
132+
);
129133
}
130134

131135
@Override

src/progressed/util/PMMathf.java

+7
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ public static Vec2 randomCirclePoint(Vec2 v, float radius){
9595
return v;
9696
}
9797

98+
public static float circleStarPoint(float theta){
99+
theta = mod(theta, 90f);
100+
theta *= degRad;
101+
float b = -2 * sqrt2 * cos(theta - pi / 4f);
102+
return (-b - sqrt(b * b - 4)) / 2;
103+
}
104+
98105
/** Pulled out of {@link Angles#moveToward(float, float, float)} */
99106
public static int angleMoveDirection(float from, float to){
100107
from = Mathf.mod(from, 360f);

0 commit comments

Comments
 (0)