mir fallen keine messages mehr ein

master
Jonathan Hager 6 years ago
parent f8db6b1e57
commit 04e075a1f5

@ -1,9 +1,5 @@
package com.dungeoncrawler.model; package com.dungeoncrawler.model;
import com.badlogic.gdx.maps.MapObject;
import com.badlogic.gdx.maps.MapObjects;
import com.badlogic.gdx.math.Rectangle;
public abstract class Entity { public abstract class Entity {
protected float xPos; protected float xPos;

@ -71,6 +71,13 @@ public class Archer extends Entity{
yPos += movementY; yPos += movementY;
} }
if(alpha >= Math.PI / -2 && alpha <= Math.PI / 2){
setDirection(1);
}
else{
setDirection(0);
}
counter++; counter++;
return false; return false;
@ -110,6 +117,13 @@ public class Archer extends Entity{
a.setMovementY(movementY); a.setMovementY(movementY);
a.setAngle(alpha); a.setAngle(alpha);
if(alpha >= Math.PI / -2 && alpha <= Math.PI / 2){
setDirection(1);
}
else{
setDirection(0);
}
return a; return a;
} }

@ -49,6 +49,8 @@ public class Swordsman extends Entity {
xPos += movementX; xPos += movementX;
yPos += movementY; yPos += movementY;
updateDirection();
return false; return false;
} }

@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.dungeoncrawler.model.Entity;
/** /**
* *
@ -45,15 +46,24 @@ public class EntitySprite {
fullCollisionSprite = sprites[0].getBoundingRectangle(); fullCollisionSprite = sprites[0].getBoundingRectangle();
} }
public void updateAnimation(boolean moves){ public void updateAnimation(Entity e){
if(attackState == 1){ if(e != null){
updateAttack(); boolean moves = false;
} if(e.getMovementX() != 0 || e.getMovementY() != 0){
else if(moves){ moves = true;
updateWalking(); }
}
else{ direction = e.getDirection();
updateIdle();
if(attackState == 1){
updateAttack();
}
else if(moves){
updateWalking();
}
else{
updateIdle();
}
} }
} }

@ -33,6 +33,7 @@ public class GameScreen {
TextureRegion[][] swordsmanRegions; TextureRegion[][] swordsmanRegions;
Texture swordsmanTexture; Texture swordsmanTexture;
Texture healthBar; Texture healthBar;
Entity[] entities;
Texture[] arrowTextures; Texture[] arrowTextures;
Sprite[] arrowSprites; Sprite[] arrowSprites;
@ -75,6 +76,8 @@ public class GameScreen {
controls.setX(-400f); controls.setX(-400f);
controls.setY(0); controls.setY(0);
*/ */
entities = d.getCurrentEntities();
//PLAYER //PLAYER
Texture[] playerTexture = new Texture[4]; Texture[] playerTexture = new Texture[4];
@ -145,7 +148,7 @@ public class GameScreen {
for(int i = 0; i < entitySprites.length; i++){ for(int i = 0; i < entitySprites.length; i++){
if(entitySprites[i] != null){ if(entitySprites[i] != null){
entitySprites[i].updateAnimation(true); entitySprites[i].updateAnimation(entities[i]);
} }
} }
} }
@ -183,6 +186,7 @@ public class GameScreen {
public void render (SpriteBatch batch, Player p, Entity[] e, int tileX, int tileY, int level, int roomPosX, int roomPosY) { public void render (SpriteBatch batch, Player p, Entity[] e, int tileX, int tileY, int level, int roomPosX, int roomPosY) {
entities = e;
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
@ -293,7 +297,7 @@ public class GameScreen {
entitySprites[i].update((int) e.getxPos(), (int) e.getyPos()); entitySprites[i].update((int) e.getxPos(), (int) e.getyPos());
if(e.getId() == 2){ if(e.getId() == 2){
entitySprites[i].getSprites()[0].setRotation((float) Math.toDegrees(e.getAngle() + Math.PI)); entitySprites[i].getSprites()[0].setRotation((float) Math.toDegrees(e.getAngle()));
} }
} }
} }

Loading…
Cancel
Save