Merge branch 'master' of git.inpt.fr:tobgang/sagittarius
BIN
core/assets/arrow0-0.png
Normal file
After Width: | Height: | Size: 783 B |
BIN
core/assets/arrow0-1.png
Normal file
After Width: | Height: | Size: 792 B |
BIN
core/assets/arrow0-2.png
Normal file
After Width: | Height: | Size: 786 B |
BIN
core/assets/arrow0-3.png
Normal file
After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -1,5 +1,7 @@
|
|||
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;
|
||||
|
@ -28,7 +30,7 @@ public class Arrow extends EntityQuad {
|
|||
private Planet crash;
|
||||
private Vector2 offset;
|
||||
|
||||
private Texture texture;
|
||||
private ArrayList<Texture> texture;
|
||||
|
||||
// ---------- CONSTRUCTORs ----------
|
||||
|
||||
|
@ -43,30 +45,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,8 +121,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,13 @@ public class GameScreen extends BaseScreen implements InputProcessor {
|
|||
@Override
|
||||
public void initialize() {
|
||||
|
||||
if (SagittariusGame.music.isPlaying()){
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/HMO-MercuryCity.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
if (!SagittariusGame.disableMusic){
|
||||
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/HMO-MercuryCity.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
|
||||
}
|
||||
|
||||
Gdx.input.setInputProcessor(this);
|
||||
|
|
|
@ -23,11 +23,12 @@ public class ResumeScreen extends BaseScreen {
|
|||
@Override
|
||||
public void initialize() {
|
||||
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
|
||||
if (!SagittariusGame.disableMusic){
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
}
|
||||
Gdx.input.setInputProcessor(uiStage);
|
||||
|
||||
// Table creation
|
||||
|
@ -62,9 +63,11 @@ public class ResumeScreen extends BaseScreen {
|
|||
// Deactivate music or not
|
||||
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()){
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.disableMusic = true;
|
||||
}
|
||||
else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){
|
||||
SagittariusGame.music.play();
|
||||
SagittariusGame.disableMusic = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,12 @@ public class SettingsScreen extends BaseScreen {
|
|||
@Override
|
||||
public void initialize() {
|
||||
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
if (!SagittariusGame.disableMusic){
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3"));
|
||||
SagittariusGame.music.setLooping(true);
|
||||
SagittariusGame.music.play();
|
||||
}
|
||||
|
||||
Gdx.input.setInputProcessor(uiStage);
|
||||
|
||||
|
@ -67,10 +69,12 @@ public class SettingsScreen extends BaseScreen {
|
|||
// Deactivate music or not
|
||||
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()){
|
||||
SagittariusGame.music.stop();
|
||||
SagittariusGame.disableMusic = true;
|
||||
}
|
||||
|
||||
else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){
|
||||
SagittariusGame.music.play();
|
||||
SagittariusGame.disableMusic = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|