Skip to content

Commit

Permalink
fix: lag after action
Browse files Browse the repository at this point in the history
  • Loading branch information
RSamaium committed Jan 12, 2024
1 parent 9592d18 commit d057e17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/common/src/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class RpgCommonGame extends EventEmitter {
}

const routesMove: any = []

while (player.pendingMove.length > 0) {
const inputData = player.pendingMove.shift()

Expand Down Expand Up @@ -131,6 +131,7 @@ export class RpgCommonGame extends EventEmitter {
input == Direction.Up ||
input == Direction.Down
) {
player.moving = true
moving = true
const isMove = await player.moveByDirection(+input, deltaTimeInt || 1)
if (isMove) {
Expand All @@ -149,6 +150,7 @@ export class RpgCommonGame extends EventEmitter {
inputs.push(input)
}


return {
player,
inputs
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class RpgServerEngine {
if (!playerInstance) continue
const player = playerInstance.otherPossessedPlayer ?? playerInstance
if (player.pendingMove.length > 0) {
player.moving = true

const lastFrame = player.pendingMove[player.pendingMove.length - 1]
if (this.inputOptions.workers) obj.push(player.toObject())
else {
Expand Down

0 comments on commit d057e17

Please sign in to comment.