master
Jonathan Hager 6 years ago
commit f543073f97

@ -215,10 +215,16 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
} }
if(delete && d.getCurrentEntities()[i].getId() == 2 || d.getCurrentEntities()[i].getToDelete()){ if(delete || d.getCurrentEntities()[i].getToDelete()){
if(d.getCurrentEntities()[i].getId() == 2){
d.getCurrentEntities()[i] = null; d.getCurrentEntities()[i] = null;
gs.deleteEntitySprite(i); gs.deleteEntitySprite(i);
} }
else{
}
}
} }
} }
} }

@ -23,6 +23,7 @@ public class Archer extends Entity{
@Override @Override
public boolean move(int xPosPlayer, int yPosPlayer) { public boolean move(int xPosPlayer, int yPosPlayer) {
if(!toDelete){
float deltaX = xPosPlayer - (int) xPos; float deltaX = xPosPlayer - (int) xPos;
float deltaY = yPosPlayer - (int) yPos; float deltaY = yPosPlayer - (int) yPos;
@ -79,13 +80,16 @@ public class Archer extends Entity{
} }
counter++; counter++;
}
return false; return false;
} }
@Override @Override
public Entity shoot(int xPosPlayer, int yPosPlayer){ public Entity shoot(int xPosPlayer, int yPosPlayer){
Arrow a = null;
if(!toDelete){
float deltaX = xPosPlayer - (int) xPos; float deltaX = xPosPlayer - (int) xPos;
float deltaY = yPosPlayer - (int) yPos; float deltaY = yPosPlayer - (int) yPos;
@ -109,7 +113,7 @@ public class Archer extends Entity{
alpha = 2*Math.PI - alpha; alpha = 2*Math.PI - alpha;
} }
} }
Arrow a = new Arrow(this.xPos, this.yPos, this.lvl, 0); a = new Arrow(this.xPos, this.yPos, this.lvl, 0);
movementX = (int) (6 * Math.cos(alpha)); movementX = (int) (6 * Math.cos(alpha));
movementY = (int) (6 * Math.sin(alpha)); movementY = (int) (6 * Math.sin(alpha));
@ -123,6 +127,7 @@ public class Archer extends Entity{
else{ else{
setDirection(0); setDirection(0);
} }
}
return a; return a;
} }

@ -19,6 +19,7 @@ public class Swordsman extends Entity {
@Override @Override
public boolean move(int xPosPlayer, int yPosPlayer){ public boolean move(int xPosPlayer, int yPosPlayer){
if(!toDelete){
float deltaX = xPosPlayer - (int) xPos; float deltaX = xPosPlayer - (int) xPos;
float deltaY = yPosPlayer - (int) yPos; float deltaY = yPosPlayer - (int) yPos;
@ -50,7 +51,7 @@ public class Swordsman extends Entity {
yPos += movementY; yPos += movementY;
updateDirection(); updateDirection();
}
return false; return false;
} }

@ -24,8 +24,7 @@ public class EntitySprite {
private TextureRegion[][][] regions; private TextureRegion[][][] regions;
private int[] frames; private int[] frames;
private int attackState; private int attackState;
private int die;
// 0: links, 1: rechts // 0: links, 1: rechts
private int direction; private int direction;
@ -34,11 +33,11 @@ public class EntitySprite {
sprites = new Sprite[1]; sprites = new Sprite[1];
regions = new TextureRegion[1][][]; regions = new TextureRegion[1][][];
// 0: idle, 1: walking, 2: attack, 3: die
// 0: idle, 1: walking, 2: attack frames = new int[4];
frames = new int[3];
direction = 0; direction = 0;
attackState = 0; attackState = 0;
die = 0;
for(int i = 0; i < sprites.length; i++){ for(int i = 0; i < sprites.length; i++){
regions[i] = TextureRegion.split(textures[i], width, height); regions[i] = TextureRegion.split(textures[i], width, height);
@ -58,7 +57,10 @@ public class EntitySprite {
direction = e.getDirection(); direction = e.getDirection();
if(attackState == 1){ if(die >= 1){
updateDie();
}
else if(attackState == 1){
updateAttack(); updateAttack();
} }
else if(moves){ else if(moves){
@ -70,6 +72,17 @@ public class EntitySprite {
} }
} }
public void updateDie(){
if(frames[3] >= 9){
die = 2;
}
else{
frames[3]++;
sprites[0].setRegion(regions[0][4][frames[3]]);
updateFlip();
}
}
public void updateAttack(){ public void updateAttack(){
frames[0] = 0; frames[0] = 0;
frames[1] = 0; frames[1] = 0;
@ -131,15 +144,12 @@ public class EntitySprite {
public void update(int xPos, int yPos){ public void update(int xPos, int yPos){
for(int i = 0; i < sprites.length; i++){ for(int i = 0; i < sprites.length; i++){
sprites[i].setPosition(xPos - 16, yPos); sprites[i].setPosition(xPos - 16, yPos);
} }
updateCollision(xPos, yPos); updateCollision(xPos, yPos);
} }
public void updateCollision(int xPos, int yPos){ public void updateCollision(int xPos, int yPos){
collisionSprite.setPosition(xPos, yPos); collisionSprite.setPosition(xPos, yPos);
getFullCollisionSprite().setPosition(xPos, yPos); getFullCollisionSprite().setPosition(xPos, yPos);
@ -158,7 +168,6 @@ public class EntitySprite {
return sprites; return sprites;
} }
/** /**
* @param sprites the sprites to set * @param sprites the sprites to set
*/ */

Loading…
Cancel
Save