Skip to content

Commit

Permalink
Scale from split source
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Apr 19, 2024
1 parent b216b29 commit 65b42e2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/progressed/content/bullets/PayloadBullets.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public static void load(){
homingPower = 0.5f;

drawZone = false;
growTime = 6f;
trailColor = targetColor = zoneColor = Pal.suppress;
trailLength = 12;
trailWidth = 1f;
Expand Down Expand Up @@ -320,6 +321,7 @@ public static void load(){
homingRange = 30f * 8f;

hitShake = 5f;
growTime = 20f;
despawnEffect = MissileFx.missileExplosion;
absorbEffect = Pseudo3DFx.absorbed;

Expand Down Expand Up @@ -534,6 +536,7 @@ public void createFrags(Bullet b, float x, float y){
enough.fragBullet = cease;
enough.arcFragDrift = 5f;
enough.targetDriftDrag = 0.01f;
enough.growTime = 20f;

ohno.fragBullet = enough;
}
Expand Down
41 changes: 28 additions & 13 deletions src/progressed/entities/bullet/pseudo3d/ArcBulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ArcBulletType extends BulletType{
public float spokeWidth = 2f, spokeLength = 8f;
public float spikeSpin = 0.5f;
public float zoneLifeOffset = 0f;
public float growTime = 6f, shrinkTime = 0f;
public float growTime = 10f, shrinkTime = 0f;
public Color zoneColor = Color.red, targetColor = Color.red;

static{
Expand Down Expand Up @@ -89,6 +89,7 @@ public void init(){
if(fragBullet instanceof ArcBulletType a){
a.isInheritive = true;
a.zoneLifeOffset = a.zoneLifeOffset * a.lifetimeScl + lifetimeScl;
shrinkTime = 0;
}

if(intervalBullet instanceof ArcBulletType a) a.isInheritive = true;
Expand Down Expand Up @@ -190,7 +191,7 @@ public void createFrags(Bullet b, float x, float y){
if(fragBullet instanceof ArcBulletType aType){
for(int i = 0; i < fragBullets; i++){
float a = b.rotation() + Mathf.range(fragRandomSpread / 2) + fragAngle + ((i - fragBullets/2f) * fragSpread);
aType.create3DInherit(b, a, aType.arcFragDrift, false);
((ArcBulletData)aType.create3DInherit(b, a, aType.arcFragDrift, false).data).splitFrom = (ArcBulletType)b.type;
}
}else{
super.createFrags(b, x, y);
Expand Down Expand Up @@ -276,20 +277,30 @@ public void drawTargetZone(Bullet b){
Draw.color(zoneColor);

float realLife = b.lifetime * lifetimeScl;
float scl = Mathf.curve(b.time, 0, growTime) - Mathf.curve(b.time, realLife - shrinkTime, realLife);
float grow = Mathf.curve(b.time, 0, growTime);
float shrink = Mathf.curve(b.time, realLife - shrinkTime, realLife);
float scl = grow - shrink;

ArcBulletType splitFrom = ((ArcBulletData)b.data).splitFrom;
boolean split = splitFrom != null;
if(split) grow = Interp.smooth.apply(grow);
float fout = 1 - shrink;

float x = b.aimX, y = b.aimY;
float ang = Mathf.randomSeed(b.id, 360) + b.time * spikeSpin;
float zR = zoneRadius * scl;
if(drawZone && zR > 0f){
if(drawZone){
float zR = split ? Mathf.lerp(splitFrom.zoneRadius, zoneRadius, grow) * fout : zoneRadius * scl;
PMDrawf.ring(x, y, zR, zR + 2f);
float sW1 = spikesWidth1 * scl, sL1 = spikesLength1 * scl;

float sW1 = split ? Mathf.lerp(splitFrom.spikesWidth1, spikesWidth1, grow) * fout : spikesWidth1 * scl,
sL1 = split ? Mathf.lerp(splitFrom.spikesLength1, spikesLength1, grow) * fout : spikesLength1 * scl;
for(int i = 0; i < 4; i++){
float a = ang + 90 * i;
Drawf.tri(x + Angles.trnsx(a, zR), y + Angles.trnsy(a, zR), sW1, sL1, a + 180);
Drawf.tri(x + Angles.trnsx(a, zR), y + Angles.trnsy(a, zR), sW1, sL1 / 2f, a);
}
float sW2 = spikesWidth2 * scl, sL2 = spikesLength2 * scl;
float sW2 = split ? Mathf.lerp(splitFrom.spikesWidth2, spikesWidth2, grow) * fout : spikesWidth2 * scl,
sL2 = split ? Mathf.lerp(splitFrom.spikesLength2, spikesLength2, grow) * fout : spikesLength2 * scl;
for(int i = 0; i < 4; i++){
float a = ang + 45 + 90 * i;
Drawf.tri(x + Angles.trnsx(a, zR), y + Angles.trnsy(a, zR), sW2, sL2, a + 180);
Expand All @@ -298,14 +309,17 @@ public void drawTargetZone(Bullet b){
}

float fin = b.fin() / lifetimeScl;
PMDrawf.progressRing(x, y, progressRadius * scl, (progressRadius + 4f) * scl, fin);

PMDrawf.ring(x, y, targetRadius * scl, (targetRadius + 2f) * scl);
Lines.stroke(spokeWidth * scl);
float tR = targetRadius * scl;
float pR = split ? Mathf.lerp(splitFrom.progressRadius, progressRadius, grow) * fout : progressRadius * scl;
PMDrawf.progressRing(x, y, pR, pR + 4f, fin);

float tR = split ? Mathf.lerp(splitFrom.targetRadius, targetRadius, grow) * fout : targetRadius * scl,
sW = split ? Mathf.lerp(splitFrom.spokeWidth, spokeWidth, grow) * fout : spokeWidth * scl,
sL = split ? Mathf.lerp(splitFrom.spokeLength, spokeLength, grow) * fout : spokeLength * scl;
PMDrawf.ring(x, y, tR, tR + 2);
Lines.stroke(sW);
for(int i = 0; i < 4; i++){
float a = -ang + 90 * i;
Lines.lineAngleCenter(x + Angles.trnsx(a, tR), y + Angles.trnsy(a, tR), a, spokeLength * scl, false);
Lines.lineAngleCenter(x + Angles.trnsx(a, tR), y + Angles.trnsy(a, tR), a, sL, false);
}
}

Expand Down Expand Up @@ -467,6 +481,7 @@ public static class ArcBulletData implements Cloneable{
public float xAccel, yAccel;
public float lastZ, z, zVel, gravity;
public float targetDriftX, targetDriftY;
public ArcBulletType splitFrom;

public ArcBulletData(float z, float zVel, float gravity){
this.z = z;
Expand Down

0 comments on commit 65b42e2

Please sign in to comment.