From 1a9c5a24f24330c75e7e3d1b3a199e29a4aadd46 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 12 May 2021 17:06:31 +0200 Subject: [PATCH] changement de couleur pas encore au point --- core/src/sagittarius/model/Player.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/sagittarius/model/Player.java b/core/src/sagittarius/model/Player.java index 14854cb..7ac381a 100644 --- a/core/src/sagittarius/model/Player.java +++ b/core/src/sagittarius/model/Player.java @@ -2,7 +2,9 @@ package sagittarius.model; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Keys; +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; @@ -28,6 +30,28 @@ 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++) { + for (int y = 0; y < pm.getHeight(); y++) { + int p = pm.getPixel(x, y); + int r = (int)( (p & 0xff000000)>>24 ); + int g = (int)( (p & 0x00ff0000)>>16 ); + int b = (int)( (p & 0x0000ff00)>>8 ); + int a = (int)( p & 0x000000ff ); + if (p != 0) { + if (r == 255 && g == 255 && b == 255) { + r = 255; + g = 0; + b = 0; + a = 255; + p = (int)( r <<24 | g << 16 | b << 8 | a ); + } + } + pm.drawPixel(x, y, p); + } + } + texture = new Texture(pm); } // ---------- METHODs ----------