Skip to content

Commit

Permalink
More interesting targetting zone
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Apr 9, 2024
1 parent 2f49325 commit 398e73f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/progressed/content/bullets/PayloadBullets.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ public static void load(){
trailWidth = 2.5f;
trailColor = Pal.sapBulletBack; //Black doesn't work because of bloom
targetColor = zoneColor = Color.black;
zoneLayer = Layer.bullet - 0.03f;

accel = 0.01f;
gravity = 0.02f;
Expand Down
46 changes: 33 additions & 13 deletions src/progressed/entities/bullet/pseudo3d/ArcBulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ public class ArcBulletType extends BulletType{
public boolean bloomTrail = true;

public boolean drawZone = false;
public float zoneLayer = Layer.bullet - 1f;
public float targetRadius = 1f, zoneRadius = 3f * 8f, shrinkRad = -1f;
public float zoneLayer = Layer.bullet;
public float targetRadius = 12f, zoneRadius = 3f * 8f;
public float shortSpikeWidth = -1f, shortSpike = -1f;
public float longSpikeWidth = -1f, longSpike = -1f;
public float spokeWidth = 2f, spokeLength = 8f;
public float spikeSpin = 0.5f;
public float zoneLifeOffset = 0f;
public Color zoneColor = Color.red, targetColor = Color.red;

Expand Down Expand Up @@ -75,6 +79,11 @@ public void initDrawSize(float range){

@Override
public void init(){
if(longSpike < 0) longSpike = zoneRadius / 2f;
if(shortSpike < 0) shortSpike = longSpike / 2f;
if(shortSpikeWidth < 0) shortSpikeWidth = shortSpike / 2f;
if(longSpikeWidth < 0) longSpikeWidth = shortSpikeWidth;

if(fragBullet instanceof ArcBulletType a){
a.isInheritive = true;
a.zoneLifeOffset = a.zoneLifeOffset * a.lifetimeScl + lifetimeScl;
Expand Down Expand Up @@ -260,20 +269,31 @@ public void drawTrail(Bullet b){
}

public void drawTargetZone(Bullet b){
Draw.z(zoneLayer - 0.01f);
Draw.z(zoneLayer);
Draw.color(zoneColor);
float x = b.aimX, y = b.aimY;
float ang = Mathf.randomSeed(b.id, 360) + b.time * spikeSpin;
if(drawZone && zoneRadius > 0f){
Draw.color(zoneColor, 0.25f + 0.25f * Mathf.absin(16f, 1f));
Fill.circle(b.aimX, b.aimY, zoneRadius);
Draw.color(zoneColor, 0.5f);
float fin = zoneLifeOffset + b.fin() * (1f - zoneLifeOffset);
float subRad = fin * (zoneRadius + shrinkRad),
inRad = Math.max(0, zoneRadius - subRad),
outRad = Math.min(zoneRadius, zoneRadius + shrinkRad - subRad);
PMDrawf.ring(x, y, zoneRadius, zoneRadius + 2f);
for(int i = 0; i < 4; i++){
float a = ang + 90 * i;
Drawf.tri(x + Angles.trnsx(a, zoneRadius), y + Angles.trnsy(a, zoneRadius), shortSpikeWidth, shortSpike, a + 180);
}
for(int i = 0; i < 4; i++){
float a = ang + 45 + 90 * i;
Drawf.tri(x + Angles.trnsx(a, zoneRadius), y + Angles.trnsy(a, zoneRadius), longSpikeWidth, longSpike, a + 180);
}
}

float fin = zoneLifeOffset + b.fin() * (1f - zoneLifeOffset);
PMDrawf.progressRing(x, y, zoneRadius + 4f, zoneRadius + 8f, fin);

PMDrawf.ring(b.aimX, b.aimY, inRad, outRad);
PMDrawf.ring(x, y, targetRadius, targetRadius + 2f);
Lines.stroke(spokeWidth);
for(int i = 0; i < 4; i++){
float a = -ang + 90 * i;
Lines.lineAngleCenter(x + Angles.trnsx(a, targetRadius), y + Angles.trnsy(a, targetRadius), a, spokeLength, false);
}
Draw.z(zoneLayer);
PMDrawf.target(b.aimX, b.aimY, Time.time * 1.5f + Mathf.randomSeed(b.id, 360f), targetRadius, targetColor != null ? targetColor : b.team.color, b.team.color, 1f);
}

@Override
Expand Down
17 changes: 17 additions & 0 deletions src/progressed/graphics/PMDrawf.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ public static void target(float x, float y, float angle, float radius, Color col
target(x, y, angle, radius, color, color, alpha);
}

public static void progressRing(float x, float y, float rad1, float rad2, float progress){
if(Math.abs(rad1 - rad2) > 0.01f){
int sides = (int)(circleVertices(Math.max(rad1, rad2)) * progress);
float space = 360f * progress / sides;

for(int i = 0; i < sides; i++){
float a = 90f - space * i, cos = Mathf.cosDeg(a), sin = Mathf.sinDeg(a), cos2 = Mathf.cosDeg(a - space), sin2 = Mathf.sinDeg(a - space);
Fill.quad(
x + rad1 * cos, y + rad1 * sin,
x + rad1 * cos2, y + rad1 * sin2,
x + rad2 * cos2, y + rad2 * sin2,
x + rad2 * cos, y + rad2 * sin
);
}
};
}

public static void ring(float x, float y, float rad1, float rad2){
if(Math.abs(rad1 - rad2) > 0.01f){
int sides = circleVertices(Math.max(rad1, rad2));
Expand Down

0 comments on commit 398e73f

Please sign in to comment.