couleur pour tous

This commit is contained in:
Damien 2021-05-12 18:59:01 +02:00
parent 2ce4167a51
commit 32f862279b
3 changed files with 46 additions and 8 deletions

View file

@ -2,6 +2,9 @@ package sagittarius.model;
import java.util.ArrayList; import java.util.ArrayList;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -46,7 +49,24 @@ public class Arrow extends EntityQuad {
this.force = computeForce(); this.force = computeForce();
this.landed = false; this.landed = false;
this.texture = new Texture("core/assets/arrow1.png"); Pixmap pm = new Pixmap(new FileHandle("core/assets/arrow1.png"));
pm.setBlending(Pixmap.Blending.None);
for (int x = 0; x < pm.getWidth(); x++) {
for (int y = 0; y < pm.getHeight(); y++) {
Color pc = new Color();
Color.rgba8888ToColor(pc, pm.getPixel(x, y));
if (pc.r == 1 && pc.g == 1 && pc.b == 1) {
pc.r = getColor().r;
pc.g = getColor().g;
pc.b = getColor().b;
}
pm.drawPixel(x, y, Color.rgba8888(pc));
}
}
texture = new Texture(pm);
} }
// ---------- METHODs ---------- // ---------- METHODs ----------

View file

@ -1,6 +1,8 @@
package sagittarius.model; package sagittarius.model;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
@ -17,7 +19,25 @@ public class Planet extends EntityCircle {
public Planet(Vector2 position, float mass, float radius, Color color) { public Planet(Vector2 position, float mass, float radius, Color color) {
super(0, mass, color, position, radius); super(0, mass, color, position, radius);
this.texture = new Texture("core/assets/planet1.png");
Pixmap pm = new Pixmap(new FileHandle("core/assets/planet1.png"));
pm.setBlending(Pixmap.Blending.None);
for (int x = 0; x < pm.getWidth(); x++) {
for (int y = 0; y < pm.getHeight(); y++) {
Color pc = new Color();
Color.rgba8888ToColor(pc, pm.getPixel(x, y));
if (pc.r == 1 && pc.g == 1 && pc.b == 1) {
pc.r = color.r;
pc.g = color.g;
pc.b = color.b;
}
pm.drawPixel(x, y, Color.rgba8888(pc));
}
}
texture = new Texture(pm);
} }
// ---------- METHODs ---------- // ---------- METHODs ----------

View file

@ -29,7 +29,6 @@ public class Player extends EntityQuad {
this.home = home; this.home = home;
this.texture = new Texture("core/assets/player1.png");
Pixmap pm = new Pixmap(new FileHandle("core/assets/player1.png")); Pixmap pm = new Pixmap(new FileHandle("core/assets/player1.png"));
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++) {
@ -38,11 +37,10 @@ public class Player extends EntityQuad {
Color pc = new Color(); Color pc = new Color();
Color.rgba8888ToColor(pc, pm.getPixel(x, y)); Color.rgba8888ToColor(pc, pm.getPixel(x, y));
if (pc.equals(Color.WHITE)) { // pc.r == 1 && pc.g == 1 && pc.b == 1 if (pc.r == 1 && pc.g == 1 && pc.b == 1) {
pc = Color.RED; pc.r = color.r;
// pc.r = 1; pc.g = color.g;
// pc.g = 0; pc.b = color.b;
// pc.b = 0;
} }
pm.drawPixel(x, y, Color.rgba8888(pc)); pm.drawPixel(x, y, Color.rgba8888(pc));