feat: dynamic texture coloring
This commit is contained in:
parent
026c2aaef9
commit
f5d9cbc011
|
@ -83,7 +83,7 @@ public class Arrow extends EntityQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw (Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
batch.draw(texture, getPosition().x - 0.8f * getWidth(), getPosition().y - getHeight()/2 - 10, 0.8f * this.getWidth(), this.getHeight()/2 + 10, getWidth(), 20 + getHeight(),
|
batch.draw(texture, getPosition().x - 0.8f * getWidth(), getPosition().y - getHeight()/2 - 10, 0.8f * this.getWidth(), this.getHeight()/2 + 10, getWidth(), 20 + getHeight(),
|
||||||
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Planet extends EntityCircle {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw (Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
batch.draw(texture, getPosition().x - this.radius, getPosition().y - this.radius, this.radius, this.radius, 2 * this.radius, 2 * this.radius,
|
batch.draw(texture, getPosition().x - this.radius, getPosition().y - this.radius, this.radius, this.radius, 2 * this.radius, 2 * this.radius,
|
||||||
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
|
|
|
@ -34,21 +34,18 @@ public class Player extends EntityQuad {
|
||||||
pm.setBlending(Pixmap.Blending.None);
|
pm.setBlending(Pixmap.Blending.None);
|
||||||
for (int x = 0; x < pm.getWidth(); x++) {
|
for (int x = 0; x < pm.getWidth(); x++) {
|
||||||
for (int y = 0; y < pm.getHeight(); y++) {
|
for (int y = 0; y < pm.getHeight(); y++) {
|
||||||
int p = pm.getPixel(x, y);
|
|
||||||
int r = (int)( (p & 0xff000000)>>24 );
|
Color pc = new Color();
|
||||||
int g = (int)( (p & 0x00ff0000)>>16 );
|
Color.rgba8888ToColor(pc, pm.getPixel(x, y));
|
||||||
int b = (int)( (p & 0x0000ff00)>>8 );
|
|
||||||
int a = (int)( p & 0x000000ff );
|
if (pc.equals(Color.WHITE)) { // pc.r == 1 && pc.g == 1 && pc.b == 1
|
||||||
if (p != 0) {
|
pc = Color.RED;
|
||||||
if (r == 255 && g == 255 && b == 255) {
|
// pc.r = 1;
|
||||||
r = 255;
|
// pc.g = 0;
|
||||||
g = 0;
|
// pc.b = 0;
|
||||||
b = 0;
|
|
||||||
a = 255;
|
|
||||||
p = (int)( r <<24 | g << 16 | b << 8 | a );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
pm.drawPixel(x, y, p);
|
pm.drawPixel(x, y, Color.rgba8888(pc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
texture = new Texture(pm);
|
texture = new Texture(pm);
|
||||||
|
@ -64,7 +61,7 @@ public class Player extends EntityQuad {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw (Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
batch.draw(texture, getPosition().x - getWidth()/2, getPosition().y - getHeight()/2, this.getWidth()/2, this.getHeight()/2, getWidth(), getHeight(),
|
batch.draw(texture, getPosition().x - getWidth()/2, getPosition().y - getHeight()/2, this.getWidth()/2, this.getHeight()/2, getWidth(), getHeight(),
|
||||||
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
|
|
Loading…
Reference in a new issue