From 0e7c0f8fb90db3f8b69852b485977a4d0d890d40 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 23 Feb 2019 14:44:27 -0800 Subject: [PATCH] Fixed entity starting direction Fixed entity starting direction Changed default angle for Player entities to -PI/2 Entities will no longer update angles to target if target is zero Re-enabled animation speeds for walk animations --- core/src/gdx/diablo/entity/Entity.java | 5 +++-- core/src/gdx/diablo/entity/Player.java | 3 +++ core/src/gdx/diablo/screen/GameScreen.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/gdx/diablo/entity/Entity.java b/core/src/gdx/diablo/entity/Entity.java index 4041dbca..a39a0072 100644 --- a/core/src/gdx/diablo/entity/Entity.java +++ b/core/src/gdx/diablo/entity/Entity.java @@ -428,9 +428,9 @@ public class Entity { // TODO: This seems to work well with the default movement speeds of most entities I've seen if (mode.equalsIgnoreCase("WL")) { - //animation.setFrameDelta(128); + animation.setFrameDelta(128); } else if (mode.equalsIgnoreCase("RN")) { - //animation.setFrameDelta(128); + animation.setFrameDelta(128); } dirty = 0; @@ -439,6 +439,7 @@ public class Entity { private boolean updateAnimation(COF cof) { if (animation == null) { animation = Animation.newAnimation(cof); + animation.setDirection(getDirection()); return true; } else { return animation.reset(cof); diff --git a/core/src/gdx/diablo/entity/Player.java b/core/src/gdx/diablo/entity/Player.java index 6f3c4101..41f71c48 100644 --- a/core/src/gdx/diablo/entity/Player.java +++ b/core/src/gdx/diablo/entity/Player.java @@ -3,6 +3,7 @@ package gdx.diablo.entity; import com.google.common.base.Preconditions; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.GdxRuntimeException; @@ -71,6 +72,7 @@ public class Player extends Entity { public Player(D2S d2s) { super(Diablo.files.PlrType.get(d2s.charClass).Token, EntType.PLAYER); setMode("TN"); + setAngle(-MathUtils.PI / 2); setWalkSpeed(6); setRunSpeed(9); setRunning(true); @@ -83,6 +85,7 @@ public class Player extends Entity { public Player(String name, int classId) { super(Diablo.files.PlrType.get(classId).Token, EntType.PLAYER); setMode("TN"); + setAngle(-MathUtils.PI / 2); setWalkSpeed(6); setRunSpeed(9); setRunning(true); diff --git a/core/src/gdx/diablo/screen/GameScreen.java b/core/src/gdx/diablo/screen/GameScreen.java index 27d37239..71860f2a 100644 --- a/core/src/gdx/diablo/screen/GameScreen.java +++ b/core/src/gdx/diablo/screen/GameScreen.java @@ -424,7 +424,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable for (Entity entity : entities.values()) { entity.update(delta); - if (!entity.position().epsilonEquals(entity.target())) { + if (!entity.target().isZero() && !entity.position().epsilonEquals(entity.target())) { float angle = mapRenderer.angle(entity.position(), entity.target()); entity.setAngle(angle); }