diff --git a/core/assets/arrow0-0.png b/core/assets/arrow0-0.png new file mode 100644 index 0000000..db0a872 Binary files /dev/null and b/core/assets/arrow0-0.png differ diff --git a/core/assets/arrow0-1.png b/core/assets/arrow0-1.png new file mode 100644 index 0000000..c3efdde Binary files /dev/null and b/core/assets/arrow0-1.png differ diff --git a/core/assets/arrow0-2.png b/core/assets/arrow0-2.png new file mode 100644 index 0000000..51c1251 Binary files /dev/null and b/core/assets/arrow0-2.png differ diff --git a/core/assets/arrow0-3.png b/core/assets/arrow0-3.png new file mode 100644 index 0000000..726a464 Binary files /dev/null and b/core/assets/arrow0-3.png differ diff --git a/core/assets/arrow0.png b/core/assets/arrow0.png deleted file mode 100644 index 0e49025..0000000 Binary files a/core/assets/arrow0.png and /dev/null differ diff --git a/core/assets/arrow1.png b/core/assets/arrow1-0.png similarity index 100% rename from core/assets/arrow1.png rename to core/assets/arrow1-0.png diff --git a/core/assets/arrow2.png b/core/assets/arrow2-0.png similarity index 100% rename from core/assets/arrow2.png rename to core/assets/arrow2-0.png diff --git a/core/assets/player1.png b/core/assets/player1.png index 565d80d..eeb0d54 100644 Binary files a/core/assets/player1.png and b/core/assets/player1.png differ diff --git a/core/src/sagittarius/SagittariusGame.java b/core/src/sagittarius/SagittariusGame.java index 175ca40..cd7b1f5 100644 --- a/core/src/sagittarius/SagittariusGame.java +++ b/core/src/sagittarius/SagittariusGame.java @@ -1,7 +1,6 @@ package sagittarius; import com.badlogic.gdx.Game; -import com.badlogic.gdx.Gdx; import com.kotcrab.vis.ui.VisUI; import com.badlogic.gdx.audio.Music; import sagittarius.view.*; diff --git a/core/src/sagittarius/model/Arrow.java b/core/src/sagittarius/model/Arrow.java index a7e0b51..8d25050 100644 --- a/core/src/sagittarius/model/Arrow.java +++ b/core/src/sagittarius/model/Arrow.java @@ -1,6 +1,8 @@ package sagittarius.model; import com.badlogic.gdx.Gdx; +import java.util.ArrayList; + import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; @@ -32,7 +34,7 @@ public class Arrow extends EntityQuad { private Sound arrowLandedSound = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/sf_fleche_plante_01.mp3")); private Sound arrowHitSound = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/VOXScrm_Cri wilhelm (ID 0477)_LS.wav")); - private Texture texture; + private ArrayList texture; // ---------- CONSTRUCTORs ---------- @@ -47,30 +49,41 @@ public class Arrow extends EntityQuad { super(0, 1, shooter.getColor(), shooter.getPosition()); this.velocity = new Vector2(power, 0).setAngleDeg(angle); this.acceleration = new Vector2(); - this.setOrigin(80, 2); - this.setSize(100, 4); + this.setOrigin(40, 2); + this.setSize(50, 4); this.force = computeForce(); this.landed = false; if (!preview) { - Pixmap pm = new Pixmap(new FileHandle("core/assets/arrow" + MathUtils.random(2) + ".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; + texture = new ArrayList<>(); + String path = "core/assets/arrow" + MathUtils.random(2); + + int i = 0; + while (true) { + try { + Pixmap pm = new Pixmap(new FileHandle(path + "-" + i + ".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)); + } } - - pm.drawPixel(x, y, Color.rgba8888(pc)); + texture.add(new Texture(pm)); + i++; + } catch (com.badlogic.gdx.utils.GdxRuntimeException e) { + break; } } - texture = new Texture(pm); } } @@ -112,8 +125,9 @@ public class Arrow extends EntityQuad { @Override 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(), - 1, 1, getRotation(), 0, 0, texture.getWidth(), texture.getHeight(), false, false); + int i = (int) (TTL * 3) % texture.size(); + batch.draw(texture.get(i), getPosition().x - getOriginX(), getPosition().y - getWidth()/2, getOriginX(), getWidth()/2, getWidth(), getWidth(), + 1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false); super.draw(batch, parentAlpha); } @@ -208,6 +222,7 @@ public class Arrow extends EntityQuad { GameScreen.setFocus(GameScreen.playerCurrent); // Make a sound when an arrow touched + GameScreen.removePlayer(player); break; } diff --git a/core/src/sagittarius/model/Bow.java b/core/src/sagittarius/model/Bow.java index e717617..f358b8e 100644 --- a/core/src/sagittarius/model/Bow.java +++ b/core/src/sagittarius/model/Bow.java @@ -8,7 +8,6 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.audio.Sound; -import com.badlogic.gdx.files.*; import sagittarius.view.GameScreen; import sagittarius.SagittariusGame; diff --git a/core/src/sagittarius/view/ResumeScreen.java b/core/src/sagittarius/view/ResumeScreen.java index 29d4b0f..ec86d66 100644 --- a/core/src/sagittarius/view/ResumeScreen.java +++ b/core/src/sagittarius/view/ResumeScreen.java @@ -3,7 +3,6 @@ package sagittarius.view; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; -import com.badlogic.gdx.utils.Align; import com.kotcrab.vis.ui.VisUI; import com.kotcrab.vis.ui.widget.VisCheckBox; import com.kotcrab.vis.ui.widget.VisTable; @@ -66,7 +65,6 @@ public class ResumeScreen extends BaseScreen { SagittariusGame.music.stop(); SagittariusGame.disableMusic = true; } - else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){ SagittariusGame.music.play(); SagittariusGame.disableMusic = false;