From 9f2b05831150c5c199c5a50268613ff07baaf49f Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 12 May 2021 14:08:43 +0200 Subject: [PATCH] maintenant les joueurs ont une texture --- core/src/sagittarius/model/Planet.java | 2 +- core/src/sagittarius/model/Player.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/sagittarius/model/Planet.java b/core/src/sagittarius/model/Planet.java index b8875e1..ec66365 100644 --- a/core/src/sagittarius/model/Planet.java +++ b/core/src/sagittarius/model/Planet.java @@ -11,7 +11,7 @@ public class Planet extends EntityCircle { // ---------- ATTRIBUTEs ---------- float revolutionRate = MathUtils.randomTriangular(1) + 1; - Texture texture; + private Texture texture; // ---------- CONSTRUCTORs ---------- diff --git a/core/src/sagittarius/model/Player.java b/core/src/sagittarius/model/Player.java index 263e6b0..6322486 100644 --- a/core/src/sagittarius/model/Player.java +++ b/core/src/sagittarius/model/Player.java @@ -3,6 +3,8 @@ package sagittarius.model; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.MathUtils; @@ -12,6 +14,7 @@ public class Player extends EntityQuad { private Planet home; private boolean active; + private Texture texture; // ---------- CONSTRUCTORs ---------- @@ -23,6 +26,8 @@ public class Player extends EntityQuad { this.setOrigin(getWidth()/2, getHeight()/2); this.home = home; + + this.texture = new Texture("core/assets/arrow2.png"); } // ---------- METHODs ---------- @@ -34,6 +39,12 @@ public class Player extends EntityQuad { shapes.line(home.getX(), home.getY(), getX(), getY()); } + @Override + 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(), + 1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false); + } + @Override public void act(float dt) { super.act(dt);