Fix walk animation speed; fix occasional camera hiccups

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-03 10:28:34 -06:00
parent 041d0223c7
commit bd57f686c7
2 changed files with 7 additions and 2 deletions

View File

@ -1441,7 +1441,7 @@ class Game {
// TODO this is not gonna be right while pausing lol
// TODO i'm not sure it'll be right when rewinding either
// TODO or if the game's speed changes. wow!
this.tic_offset = (performance.now() - this.last_advance) / 1000 / (1 / TICS_PER_SECOND) % 1;
this.tic_offset = Math.min(1, (performance.now() - this.last_advance) / 1000 / (1 / TICS_PER_SECOND));
this._redraw();
this._redraw_handle = requestAnimationFrame(this._redraw_bound);

View File

@ -499,8 +499,13 @@ export class Tileset {
}
if (coords[0] instanceof Array) {
if (level) {
if (tile.animation_speed) {
coords = coords[Math.floor((tile.animation_progress + level.tic_offset) / tile.animation_speed * coords.length * 0.999)];
}
else {
coords = coords[Math.floor((level.tic_counter % 5 + level.tic_offset) / 5 * coords.length)];
}
}
else {
coords = coords[0];
}