diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index f2507f4..282c73a 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -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(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(mm != null){} if(gs != null && gs.getIsLoading() == false){ diff --git a/core/src/com/dungeoncrawler/view/EntitySprite.java b/core/src/com/dungeoncrawler/view/EntitySprite.java index eb5ffbc..64d7239 100644 --- a/core/src/com/dungeoncrawler/view/EntitySprite.java +++ b/core/src/com/dungeoncrawler/view/EntitySprite.java @@ -25,11 +25,6 @@ public class EntitySprite { private int[] frames; private int attackState; - private Texture healthBarContainerTexture; - private Sprite healthBarContainerSprite; - private Texture healthBarTexture; - private Sprite healthBarSprite; - boolean healthBarExists; // 0: links, 1: rechts @@ -39,7 +34,6 @@ public class EntitySprite { sprites = new Sprite[1]; regions = new TextureRegion[1][][]; - healthBarExists = true; // 0: idle, 1: walking, 2: attack frames = new int[3]; @@ -137,30 +131,13 @@ public class EntitySprite { public void update(int xPos, int yPos){ for(int i = 0; i < sprites.length; i++){ sprites[i].setPosition(xPos - 16, yPos); - if(healthBarExists == true){ - } + } updateCollision(xPos, yPos); } - public void updateHealthBar(float hp, float maxHp, float xPos, float 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; - } - public void updateCollision(int xPos, int yPos){ @@ -181,15 +158,7 @@ public class EntitySprite { return sprites; } - public Sprite getHealthBarContainerSprite(){ - return healthBarContainerSprite; - } - public Sprite getHealthBarSprite(){ - return healthBarSprite; - } - public boolean healthBarIsExisting(){ - return healthBarExists; - } + /** * @param sprites the sprites to set */ diff --git a/core/src/com/dungeoncrawler/view/GameScreen.java b/core/src/com/dungeoncrawler/view/GameScreen.java index 4e4ec7d..7aea6a8 100644 --- a/core/src/com/dungeoncrawler/view/GameScreen.java +++ b/core/src/com/dungeoncrawler/view/GameScreen.java @@ -302,8 +302,8 @@ public class GameScreen { entitySprites[i] = null; } - public Entity[] playerAttack(Entity e[], Player p, SpriteBatch batch){ - if(p.getDirection() == 0){ + public Entity[] playerAttack(Entity e[], Player p, int attackDirection, SpriteBatch batch){ + if(attackDirection == 0){ Texture attackTexture = new Texture("sprites/AttackHori.png"); Sprite attackSprite = new Sprite(attackTexture); 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"); Sprite attackSprite = new Sprite(attackTexture); 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"); Sprite attackSprite = new Sprite(attackTexture); 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"); Sprite attackSprite = new Sprite(attackTexture); attackSprite.setX(p.getxPos() - 32f);