Skip to content

Commit

Permalink
Use ActiveEntity.getFaceDirection to determine sprite drawing...
Browse files Browse the repository at this point in the history
...index. Defaults to "down" when facing direction cannot be determined.

Closes: #721
  • Loading branch information
AntumDeluge committed Jun 22, 2024
1 parent 542fe5b commit 8ede1b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/js/stendhal/entity/RPEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,14 @@ export class RPEntity extends ActiveEntity {
if (image.height) { // image.complete is true on missing image files
var nFrames = 3;
var nDirections = 4;
var yRow = this["dir"] - 1;
const facing = this.getFaceDirection().val;
var yRow = facing - 1;
var frame = 1; // draw center column when idle
// Ents are a hack in Java client too
if (this["class"] == "ent") {
nFrames = 1;
nDirections = 2;
yRow = Math.floor((this["dir"] - 1) / 2);
yRow = Math.floor((facing - 1) / 2);
frame = 0;
}
this["drawHeight"] = image.height as number / nDirections;
Expand Down

0 comments on commit 8ede1b8

Please sign in to comment.