From 32f862279bd54d0edeec35e587502cb19cb78ecd Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 12 May 2021 18:59:01 +0200 Subject: [PATCH] couleur pour tous --- core/src/sagittarius/model/Arrow.java | 22 +++++++++++++++++++++- core/src/sagittarius/model/Planet.java | 22 +++++++++++++++++++++- core/src/sagittarius/model/Player.java | 10 ++++------ 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/core/src/sagittarius/model/Arrow.java b/core/src/sagittarius/model/Arrow.java index 73d6996..6d72e56 100644 --- a/core/src/sagittarius/model/Arrow.java +++ b/core/src/sagittarius/model/Arrow.java @@ -2,6 +2,9 @@ package sagittarius.model; 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.g2d.Batch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; @@ -46,7 +49,24 @@ public class Arrow extends EntityQuad { this.force = computeForce(); 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 ---------- diff --git a/core/src/sagittarius/model/Planet.java b/core/src/sagittarius/model/Planet.java index 58b4f67..89078a1 100644 --- a/core/src/sagittarius/model/Planet.java +++ b/core/src/sagittarius/model/Planet.java @@ -1,6 +1,8 @@ package sagittarius.model; +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.g2d.Batch; 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) { 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 ---------- diff --git a/core/src/sagittarius/model/Player.java b/core/src/sagittarius/model/Player.java index d260716..28682ce 100644 --- a/core/src/sagittarius/model/Player.java +++ b/core/src/sagittarius/model/Player.java @@ -29,7 +29,6 @@ public class Player extends EntityQuad { this.home = home; - this.texture = new Texture("core/assets/player1.png"); Pixmap pm = new Pixmap(new FileHandle("core/assets/player1.png")); pm.setBlending(Pixmap.Blending.None); for (int x = 0; x < pm.getWidth(); x++) { @@ -38,11 +37,10 @@ public class Player extends EntityQuad { Color pc = new Color(); Color.rgba8888ToColor(pc, pm.getPixel(x, y)); - if (pc.equals(Color.WHITE)) { // pc.r == 1 && pc.g == 1 && pc.b == 1 - pc = Color.RED; - // pc.r = 1; - // pc.g = 0; - // pc.b = 0; + 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));