Skip to content

Commit

Permalink
✨ Transparent tail
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed Oct 18, 2020
1 parent 78e1960 commit aef0e2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 5 additions & 3 deletions app/src/main/java/sma/rhythmtapper/game/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@ public void paint(float deltaTime) {
for (HelperLine h : helperLines) {
h.Paint(g);
}
for (Connector tail : aliveTails) {
tail.Paint(g);
}

for (List<Ball> bals : _balls) {
for (Ball b : bals) {
Expand All @@ -1147,6 +1144,11 @@ public void paint(float deltaTime) {
}
}
}

for (Connector tail : aliveTails) {
tail.Paint(g);
}

if (state == GameState.Running)
drawRunningUI();
//if (_explosionTicker > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Connector implements Serializable {
float difftime;
float diffY;

final int COLORCONNECTOR = Color.argb(0x77, 0xFF, 0xFF, 0xFF);


//Ball1 is first (lower)
public Connector(Ball ball1, Ball ball2) {
Expand All @@ -35,7 +37,7 @@ public void Paint(Graphics g) {
UpdateGhosts();
// }
if (ball1.alive)
g.drawLine(ghost1x, ghost1y, ghost2x, ghost2y, Color.LTGRAY, (int) (50 * GameScreen.getSizeCoeff(ball1.t)));
g.drawLine(ghost1x, ghost1y, ghost2x, ghost2y, COLORCONNECTOR, (int) (50 * GameScreen.getSizeCoeff(ball1.t)));
/*if(ghost1y > EnvVar.HITBOX_CENTER && ghost2y <EnvVar.HITBOX_CENTER) {
int helperx = (GameScreen.HITBOX_CENTER - ghost1y) * (ghost2x - ghost1x) / (ghost2y - ghost1y) + ghost1x;
g.drawImage(Assets.ballHitpoint, (int) (helperx - SIZE_BALL), (int) (EnvVar.HITBOX_CENTER - SIZE_BALL)
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/sma/rhythmtapper/game/models/Tail.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
public class Tail extends Connector {
private final boolean optimized;
private boolean created = false;
final int STROKE = 60;
final int STROKE = 70;

final int TAILCOLOR = Color.argb(0x99, 0xFF, 0xFF, 0xFF);

public Tail(Ball ball1, Ball ball2) {
super(ball1, ball2);
Expand Down Expand Up @@ -145,9 +147,11 @@ public void Paint(Graphics g) {
float m2 = ball2.origx;
float n2 = ball2.endx;
float timeDelta = ball2.time - ball1.time;
final float dt = 0.05f;
final float dt = 0.04f;
float prevX = ball1.x;
float prevY = ball1.y;
float prevprevX = ball1.x;
float prevprevY = ball1.y;
// m1...n1
// ...
// m2...n2
Expand All @@ -171,15 +175,17 @@ public void Paint(Graphics g) {
float z = (int) (DEPTH * (time - EnvVar.currentTime) * EnvVar.speed / 50);
float y = (int) (aOfZ * (z - alphaDepth) * (z - alphaDepth));

g.drawLine((int) prevX, (int) prevY, (int) x, (int) y, Color.WHITE, STROKE);
g.drawLine((int) prevprevX, (int) prevprevY, (int) x, (int) y, TAILCOLOR, STROKE);

prevprevX = prevX;
prevprevY = prevY;
prevX = x;
prevY = y;

}
// if(time < ball2.time)
if(ball2.y <= prevY)
g.drawLine((int) prevX, (int) prevY, ball2.x, ball2.y, Color.WHITE, STROKE);
g.drawLine((int) prevprevX, (int) prevprevY, ball2.x, ball2.y, TAILCOLOR, STROKE);
}

public float mn2x(float m, float n, float t) {
Expand Down

0 comments on commit aef0e2a

Please sign in to comment.