mir fallen keine messages mehr ein

master
Jonathan Hager 6 years ago
parent f8db6b1e57
commit 04e075a1f5

@ -1,9 +1,5 @@
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 {
protected float xPos;

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

@ -49,6 +49,8 @@ public class Swordsman extends Entity {
xPos += movementX;
yPos += movementY;
updateDirection();
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.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.dungeoncrawler.model.Entity;
/**
*
@ -45,15 +46,24 @@ public class EntitySprite {
fullCollisionSprite = sprites[0].getBoundingRectangle();
}
public void updateAnimation(boolean moves){
if(attackState == 1){
updateAttack();
}
else if(moves){
updateWalking();
}
else{
updateIdle();
public void updateAnimation(Entity e){
if(e != null){
boolean moves = false;
if(e.getMovementX() != 0 || e.getMovementY() != 0){
moves = true;
}
direction = e.getDirection();
if(attackState == 1){
updateAttack();
}
else if(moves){
updateWalking();
}
else{
updateIdle();
}
}
}

@ -33,6 +33,7 @@ public class GameScreen {
TextureRegion[][] swordsmanRegions;
Texture swordsmanTexture;
Texture healthBar;
Entity[] entities;
Texture[] arrowTextures;
Sprite[] arrowSprites;
@ -75,6 +76,8 @@ public class GameScreen {
controls.setX(-400f);
controls.setY(0);
*/
entities = d.getCurrentEntities();
//PLAYER
Texture[] playerTexture = new Texture[4];
@ -145,7 +148,7 @@ public class GameScreen {
for(int i = 0; i < entitySprites.length; i++){
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) {
entities = e;
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
@ -293,7 +297,7 @@ public class GameScreen {
entitySprites[i].update((int) e.getxPos(), (int) e.getyPos());
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