diff --git a/res/img/tiles16.xcf b/res/img/tiles16.xcf index 74e1b6b..a8bbd43 100644 Binary files a/res/img/tiles16.xcf and b/res/img/tiles16.xcf differ diff --git a/src/mightypork/rogue/world/entity/Entity.java b/src/mightypork/rogue/world/entity/Entity.java index abd0f30..182b2ac 100644 --- a/src/mightypork/rogue/world/entity/Entity.java +++ b/src/mightypork/rogue/world/entity/Entity.java @@ -42,15 +42,14 @@ public final class Entity implements IonBinary, IonBundled, EntityMoveListener { private final Queue path = new LinkedList<>(); // saved private EntityModel model; - public final IonBundle metadata = new IonBundle(); // saved - public final IonBundle tmpdata = new IonBundle(); // NOT saved + public final IonBundle metadata = new IonBundle(); // saved - // used for rendering "facing" sprite - public int lastXMove = 1; - public int lastYMove = 1; + /** Some infos for/by the renderer, not saved */ + public final EntityRenderData renderData = new EntityRenderData(); private final List moveListeners = new ArrayList<>(); + // tmp flag private boolean walking = false; @@ -200,8 +199,8 @@ public final class Entity implements IonBinary, IonBundled, EntityMoveListener { } else { // tmp for renderer - if (step.x != 0) lastXMove = step.x; - if (step.y != 0) lastYMove = step.y; + if (step.x != 0) renderData.lastXDir = step.x; + if (step.y != 0) renderData.lastYDir = step.y; position.walk(step.x, step.y, getStepTime()); level.occupyTile(projX, projY); diff --git a/src/mightypork/rogue/world/entity/EntityRenderData.java b/src/mightypork/rogue/world/entity/EntityRenderData.java new file mode 100644 index 0000000..31838b6 --- /dev/null +++ b/src/mightypork/rogue/world/entity/EntityRenderData.java @@ -0,0 +1,14 @@ +package mightypork.rogue.world.entity; + + +/** + * Data storage for renderer / entity. + * + * @author MightyPork + */ +public class EntityRenderData { + + public int lastXDir = 1; + public int lastYDir = 1; + +} diff --git a/src/mightypork/rogue/world/entity/renderers/PlayerRenderer.java b/src/mightypork/rogue/world/entity/renderers/PlayerRenderer.java index 4d55216..adb2a94 100644 --- a/src/mightypork/rogue/world/entity/renderers/PlayerRenderer.java +++ b/src/mightypork/rogue/world/entity/renderers/PlayerRenderer.java @@ -19,7 +19,7 @@ public class PlayerRenderer extends EntityRenderer { public PlayerRenderer(String sheetKey) { - this.sheet = Res.getTxSheet(sheetKey); // expects 1x4 + this.sheet = Res.getTxSheet(sheetKey); } @@ -28,14 +28,14 @@ public class PlayerRenderer extends EntityRenderer { { TxQuad q = sheet.getQuad(Calc.frag(entity.getPosition().getProgress())); - if (entity.lastXMove == -1) q = q.flipX(); + if (entity.renderData.lastXDir == -1) q = q.flipX(); final WorldPos pos = entity.getPosition(); final Rect tileRect = context.getRectForTile(pos.x, pos.y); final double w = tileRect.width().value(); - Rect spriteRect = tileRect.move(pos.getVisualXOffset() * w, pos.getVisualYOffset() * w + w * 0.1); + Rect spriteRect = tileRect.move(pos.getVisualXOffset() * w, pos.getVisualYOffset() * w); spriteRect = spriteRect.shrink(w * 0.1); Render.quadTextured(spriteRect, q);