little changes

v5stable
Ondřej Hruška 11 years ago
parent 6761b69b63
commit facec9d6d3
  1. BIN
      res/img/tiles16.xcf
  2. 11
      src/mightypork/rogue/world/entity/Entity.java
  3. 14
      src/mightypork/rogue/world/entity/EntityRenderData.java
  4. 6
      src/mightypork/rogue/world/entity/renderers/PlayerRenderer.java

Binary file not shown.

@ -43,14 +43,13 @@ public final class Entity implements IonBinary, IonBundled, EntityMoveListener {
private final Queue<PathStep> path = new LinkedList<>(); // saved
private EntityModel model;
public final IonBundle metadata = new IonBundle(); // saved
public final IonBundle tmpdata = new IonBundle(); // NOT 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<EntityMoveListener> 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);

@ -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;
}

@ -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);

Loading…
Cancel
Save