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
This commit is contained in:
Collin Smith 2019-02-23 14:44:27 -08:00
parent 18acef4791
commit 0e7c0f8fb9
3 changed files with 7 additions and 3 deletions

View File

@ -428,9 +428,9 @@ public class Entity {
// TODO: This seems to work well with the default movement speeds of most entities I've seen // TODO: This seems to work well with the default movement speeds of most entities I've seen
if (mode.equalsIgnoreCase("WL")) { if (mode.equalsIgnoreCase("WL")) {
//animation.setFrameDelta(128); animation.setFrameDelta(128);
} else if (mode.equalsIgnoreCase("RN")) { } else if (mode.equalsIgnoreCase("RN")) {
//animation.setFrameDelta(128); animation.setFrameDelta(128);
} }
dirty = 0; dirty = 0;
@ -439,6 +439,7 @@ public class Entity {
private boolean updateAnimation(COF cof) { private boolean updateAnimation(COF cof) {
if (animation == null) { if (animation == null) {
animation = Animation.newAnimation(cof); animation = Animation.newAnimation(cof);
animation.setDirection(getDirection());
return true; return true;
} else { } else {
return animation.reset(cof); return animation.reset(cof);

View File

@ -3,6 +3,7 @@ package gdx.diablo.entity;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.GdxRuntimeException;
@ -71,6 +72,7 @@ public class Player extends Entity {
public Player(D2S d2s) { public Player(D2S d2s) {
super(Diablo.files.PlrType.get(d2s.charClass).Token, EntType.PLAYER); super(Diablo.files.PlrType.get(d2s.charClass).Token, EntType.PLAYER);
setMode("TN"); setMode("TN");
setAngle(-MathUtils.PI / 2);
setWalkSpeed(6); setWalkSpeed(6);
setRunSpeed(9); setRunSpeed(9);
setRunning(true); setRunning(true);
@ -83,6 +85,7 @@ public class Player extends Entity {
public Player(String name, int classId) { public Player(String name, int classId) {
super(Diablo.files.PlrType.get(classId).Token, EntType.PLAYER); super(Diablo.files.PlrType.get(classId).Token, EntType.PLAYER);
setMode("TN"); setMode("TN");
setAngle(-MathUtils.PI / 2);
setWalkSpeed(6); setWalkSpeed(6);
setRunSpeed(9); setRunSpeed(9);
setRunning(true); setRunning(true);

View File

@ -424,7 +424,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
for (Entity entity : entities.values()) { for (Entity entity : entities.values()) {
entity.update(delta); 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()); float angle = mapRenderer.angle(entity.position(), entity.target());
entity.setAngle(angle); entity.setAngle(angle);
} }