master
GammelJan 6 years ago
parent 0e8f29cc6a
commit fbda4e48fe

@ -463,12 +463,33 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
} }
if(keycode == Input.Keys.E){ if(keycode == Input.Keys.UP){
if(mm != null){} if(mm != null){}
if(gs != null && gs.getIsLoading() == false){ if(gs != null && gs.getIsLoading() == false){
d.setCurrentEntities(gs.playerAttack(d.getCurrentEntities(), d.getPlayer(), batch)); d.setCurrentEntities(gs.playerAttack(d.getCurrentEntities(), d.getPlayer(), 0, batch));
} }
} }
if(keycode == Input.Keys.RIGHT){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
d.setCurrentEntities(gs.playerAttack(d.getCurrentEntities(), d.getPlayer(), 1, batch));
}
}
if(keycode == Input.Keys.DOWN){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
d.setCurrentEntities(gs.playerAttack(d.getCurrentEntities(), d.getPlayer(), 2, batch));
}
}
if(keycode == Input.Keys.LEFT){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
d.setCurrentEntities(gs.playerAttack(d.getCurrentEntities(), d.getPlayer(), 3, batch));
}
}
if(keycode == Input.Keys.F){ if(keycode == Input.Keys.F){
if(mm != null){} if(mm != null){}
if(gs != null && gs.getIsLoading() == false){ if(gs != null && gs.getIsLoading() == false){

@ -25,11 +25,6 @@ public class EntitySprite {
private int[] frames; private int[] frames;
private int attackState; private int attackState;
private Texture healthBarContainerTexture;
private Sprite healthBarContainerSprite;
private Texture healthBarTexture;
private Sprite healthBarSprite;
boolean healthBarExists;
// 0: links, 1: rechts // 0: links, 1: rechts
@ -39,7 +34,6 @@ public class EntitySprite {
sprites = new Sprite[1]; sprites = new Sprite[1];
regions = new TextureRegion[1][][]; regions = new TextureRegion[1][][];
healthBarExists = true;
// 0: idle, 1: walking, 2: attack // 0: idle, 1: walking, 2: attack
frames = new int[3]; frames = new int[3];
@ -137,28 +131,11 @@ 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);
if(healthBarExists == true){
}
}
updateCollision(xPos, yPos);
} }
public void updateHealthBar(float hp, float maxHp, float xPos, float yPos){ updateCollision(xPos, yPos);
float n = hp / maxHp;
healthBarTexture = new Texture("sprites/entityHealthBar.png");
int newWidth = (int) (n * healthBarTexture.getWidth());
TextureRegion[][] playerHealthRegion = TextureRegion.split(healthBarTexture,newWidth, healthBarTexture.getHeight());
healthBarSprite = new Sprite(playerHealthRegion[0][0]);
healthBarSprite.setPosition(xPos, yPos);
healthBarContainerSprite.setPosition(xPos, yPos);
}
public void createHealthBar(){
healthBarContainerTexture = new Texture("sprites/entityHealthBarContainer.png");
healthBarContainerSprite = new Sprite(healthBarContainerTexture);
healthBarExists = true;
} }
@ -181,15 +158,7 @@ public class EntitySprite {
return sprites; return sprites;
} }
public Sprite getHealthBarContainerSprite(){
return healthBarContainerSprite;
}
public Sprite getHealthBarSprite(){
return healthBarSprite;
}
public boolean healthBarIsExisting(){
return healthBarExists;
}
/** /**
* @param sprites the sprites to set * @param sprites the sprites to set
*/ */

@ -302,8 +302,8 @@ public class GameScreen {
entitySprites[i] = null; entitySprites[i] = null;
} }
public Entity[] playerAttack(Entity e[], Player p, SpriteBatch batch){ public Entity[] playerAttack(Entity e[], Player p, int attackDirection, SpriteBatch batch){
if(p.getDirection() == 0){ if(attackDirection == 0){
Texture attackTexture = new Texture("sprites/AttackHori.png"); Texture attackTexture = new Texture("sprites/AttackHori.png");
Sprite attackSprite = new Sprite(attackTexture); Sprite attackSprite = new Sprite(attackTexture);
attackSprite.setX(p.getxPos() - 8f); attackSprite.setX(p.getxPos() - 8f);
@ -324,7 +324,7 @@ public class GameScreen {
} }
} }
} }
else if(p.getDirection()== 1){ else if(attackDirection== 1){
Texture attackTexture = new Texture("sprites/AttackVert.png"); Texture attackTexture = new Texture("sprites/AttackVert.png");
Sprite attackSprite = new Sprite(attackTexture); Sprite attackSprite = new Sprite(attackTexture);
attackSprite.setX(p.getxPos()+ 32f); attackSprite.setX(p.getxPos()+ 32f);
@ -344,7 +344,7 @@ public class GameScreen {
} }
} }
} }
else if(p.getDirection()== 2){ else if(attackDirection== 2){
Texture attackTexture = new Texture("sprites/AttackHori.png"); Texture attackTexture = new Texture("sprites/AttackHori.png");
Sprite attackSprite = new Sprite(attackTexture); Sprite attackSprite = new Sprite(attackTexture);
attackSprite.setX(p.getxPos() - 8f); attackSprite.setX(p.getxPos() - 8f);
@ -364,7 +364,7 @@ public class GameScreen {
} }
} }
} }
else if(p.getDirection()== 3){ else if(attackDirection== 3){
Texture attackTexture = new Texture("sprites/AttackVert.png"); Texture attackTexture = new Texture("sprites/AttackVert.png");
Sprite attackSprite = new Sprite(attackTexture); Sprite attackSprite = new Sprite(attackTexture);
attackSprite.setX(p.getxPos() - 32f); attackSprite.setX(p.getxPos() - 32f);

Loading…
Cancel
Save