Draw player code duplicated
JohnathonNow opened this issue · comments
Bending/src/main/java/com/johnwesthoff/bending/destruct/World.java
Lines 974 to 1097 in 92f06d2
public void drawPlayers(Graphics g) { | |
float offs = x % 8; | |
if ((status & World.ST_INVISIBLE) == 0) { | |
if (!done) { | |
// x+=move; | |
g.drawArc((int) ((x - 2) - viewX) * Constants.WIDTH_SCALE, (int) ((y - 10) - viewY) * Constants.HEIGHT_SCALE, 4, 4, 0, 360); | |
g.drawLine((int) ((x) - viewX) * Constants.WIDTH_SCALE, (int) ((y - 6) - viewY) * Constants.HEIGHT_SCALE, (int) ((x) - viewX) * Constants.WIDTH_SCALE, | |
(int) ((y - 3) - viewY) * Constants.HEIGHT_SCALE); | |
g.drawLine((int) ((x - 2) - viewX) * Constants.WIDTH_SCALE, (int) ((y - 4) - viewY) * Constants.HEIGHT_SCALE, (int) ((x + 2) - viewX) * Constants.WIDTH_SCALE, | |
(int) ((y - 4) - viewY) * Constants.HEIGHT_SCALE); | |
g.drawLine((int) ((x) - viewX) * Constants.WIDTH_SCALE, (int) ((y - 3) - viewY) * Constants.HEIGHT_SCALE, (int) ((x + offs - 2) - viewX) * Constants.WIDTH_SCALE, | |
(int) ((y) - viewY) * Constants.HEIGHT_SCALE); | |
g.drawLine((int) ((x) - viewX) * Constants.WIDTH_SCALE, (int) ((y - 3) - viewY) * Constants.HEIGHT_SCALE, (int) ((x + 2 - offs) - viewX) * Constants.WIDTH_SCALE, (int) ((y) - viewY) * Constants.HEIGHT_SCALE); | |
} else { | |
int yUp = 20; | |
if (Math.signum(move) == -1) { | |
left = -1; | |
} | |
if (Math.signum(move) == 1) { | |
left = 1; | |
} | |
Graphics2D g2 = (Graphics2D) g; | |
AffineTransform swag = g2.getTransform(); | |
g2.scale(left, 1); | |
g2.drawImage(bodyParts[0], (int) (x - viewX) * Constants.WIDTH_SCALE * left + (left < 0 ? -18 : 0), | |
(int) (y - yUp - 6 - viewY) * Constants.HEIGHT_SCALE, null); | |
g2.drawImage(bodyParts[1], | |
(int) (x + 2 - ((bodyParts[1].getWidth(null) - 23) / 5) - viewX) * Constants.WIDTH_SCALE * left | |
+ (left < 0 ? -(6 + (bodyParts[1].getWidth(null) - 23)) : 0), | |
(int) ((y - yUp - 16 - ((bodyParts[1].getHeight(null) - 31)) / 3) - viewY) * Constants.HEIGHT_SCALE, null); | |
double ffs = Math.toRadians(((4 - offs) * 6)); | |
if (vspeed != 0) | |
ffs = Math.toRadians(((4 - 5) * 6)); | |
AffineTransform previousAT = g2.getTransform(); | |
int ddd = bodyParts[3].getWidth(null); | |
// System.out.println(ddd); | |
if (ddd == 48) { | |
g2.translate((x - 3 - viewX) * Constants.WIDTH_SCALE * left, ((y - yUp - 6) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(leftArmAngle - 90), 4 * (left + 1), 2); | |
g2.drawImage(bodyParts[2], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate( | |
(((x - 3 - viewX) + this.lengthdir_x(6 * left, leftArmAngle * left))) * left * (Constants.WIDTH_SCALE-0.05) | |
+ ((left - 1) * 10), | |
(((y - yUp - 6) - this.lengthdir_y(6 * left, leftArmAngle * left)) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(leftArmAngle - 90), (left == 1) ? 17 : 13, 2); | |
g2.drawImage(bodyParts[3], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate((x + 9 - viewX) * Constants.WIDTH_SCALE * left, ((y - yUp - 6) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(rightArmAngle - 90), 0, 2); | |
g2.drawImage(bodyParts[2], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate( | |
(((x + 9 - viewX) + this.lengthdir_x(6 * left, rightArmAngle * left)) * (Constants.WIDTH_SCALE-0.05)) * left | |
+ ((left - 1) * 10), | |
(((y - yUp - 6) - this.lengthdir_y(6 * left, rightArmAngle * left)) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(rightArmAngle - 90), 12, 2); | |
g2.drawImage(bodyParts[3], 0, 0, null); | |
g2.setTransform(previousAT); | |
} else { | |
g2.translate((x - 3 - viewX) * Constants.WIDTH_SCALE * left, ((y - yUp - 6) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(leftArmAngle - 90), 4 * (left + 1), 2); | |
g2.drawImage(bodyParts[2], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate((((x + 9 - viewX) + this.lengthdir_x(6 * left, rightArmAngle * left)) * Constants.WIDTH_SCALE) * left, | |
(((y - yUp - 6) - this.lengthdir_y(6 * left, rightArmAngle * left)) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(rightArmAngle - 90), 8 - left * 4, 4); | |
g2.drawImage(bodyParts[3], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate((x + 9 - viewX) * Constants.WIDTH_SCALE * left, ((y - yUp - 6) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(rightArmAngle - 90), 8 - left * 4, 4); | |
g2.drawImage(bodyParts[2], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate((((x - 3 - viewX) + this.lengthdir_x(6 * left, leftArmAngle * left))) * left * Constants.WIDTH_SCALE, | |
(((y - yUp - 6) - this.lengthdir_y(6 * left, leftArmAngle * left)) - viewY) * Constants.HEIGHT_SCALE); | |
g2.rotate(Math.toRadians(leftArmAngle - 90), 4 * (left + 1), 2); | |
g2.drawImage(bodyParts[3], 0, 0, null); | |
g2.setTransform(previousAT); | |
} | |
// | |
// g2.translate((x+9-viewX)*3*left, ((y-yUp-6)-viewY)*3); | |
// g2.rotate(Math.toRadians(rightArmAngle-90),0,2); | |
// g2.drawImage(bodyParts[2], 0, 0, null); | |
// g2.setTransform(previousAT); | |
// | |
// g2.translate((((x+9-viewX)+this.lengthdir_x(6*left, | |
// rightArmAngle*left))*3)*left, | |
// (((y-yUp-6)-this.lengthdir_y(6*left,rightArmAngle*left))-viewY)*3); | |
// g2.rotate(Math.toRadians(rightArmAngle-90),0,2); | |
// g2.drawImage(bodyParts[3], 0, 0, null); | |
// g2.setTransform(previousAT); | |
g2.drawImage(bodyParts[4], (int) (x + 1 - viewX) * Constants.WIDTH_SCALE * left, (int) ((y - yUp + 7) - viewY) * Constants.HEIGHT_SCALE, null); | |
g2.drawImage(bodyParts[4], (int) (x + 5 - viewX) * Constants.WIDTH_SCALE * left, (int) ((y - yUp + 7) - viewY) * Constants.HEIGHT_SCALE, null); | |
g2.translate((x + 5 - viewX) * Constants.WIDTH_SCALE * left, ((y + 13) - viewY - yUp) * Constants.HEIGHT_SCALE); | |
g2.rotate(ffs); | |
g2.drawImage(bodyParts[5], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.translate((x + 1 - viewX) * Constants.WIDTH_SCALE * left, ((y + 13) - viewY - yUp) * Constants.HEIGHT_SCALE); | |
g2.rotate(-ffs); | |
g2.drawImage(bodyParts[5], 0, 0, null); | |
g2.setTransform(previousAT); | |
g2.scale(left, 1); | |
if (((status & ST_FLAMING)) != 0) { | |
drawFire(g2, (int) (x + 4 - viewX) * Constants.WIDTH_SCALE, (int) (y - viewY) * Constants.HEIGHT_SCALE); | |
} | |
if (((status & ST_DRAIN)) != 0) { | |
g2.setColor(Color.BLACK); | |
g2.drawArc((int) (x - viewX - (AURA_RADIUS / 2)) * Constants.WIDTH_SCALE, (int) (y - viewY - (AURA_RADIUS)) * Constants.HEIGHT_SCALE, | |
AURA_RADIUS * Constants.WIDTH_SCALE, AURA_RADIUS * Constants.HEIGHT_SCALE, random.nextInt(360), random.nextInt(90)); | |
} | |
g2.setTransform(swag); | |
} | |
} |
The code for drawing the player playing the game is separate from the code that draws the players they are playing with. This should not be the case.
In fact, a lot of code is duplicated in this way for players, and this should be sorted out.
Hii, can you check my PR?
Yes, when I get a chance I will
…On Sat, Oct 3, 2020, 12:26 AM Wdestroier ***@***.***> wrote:
Hii, can you check my PR?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJ6G7L56MGXI5U7H37DD2TSI2RYLANCNFSM4RK4W65Q>
.