Skip to content

Commit

Permalink
Fix spectate mode only showing a part of the game
Browse files Browse the repository at this point in the history
In spectate mode, the center of view was not being set properly,
therefore the spectator could only see a part of the game. Fixed that
by updating the player coordinates on 'resize' events.
  • Loading branch information
Eduardo L. Buratti committed Jul 23, 2016
1 parent d46bfbf commit 8a1a8f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,11 @@ window.addEventListener('resize', resize);
function resize() {
player.screenWidth = c.width = global.screenWidth = global.playerType == 'player' ? window.innerWidth : global.gameWidth;
player.screenHeight = c.height = global.screenHeight = global.playerType == 'player' ? window.innerHeight : global.gameHeight;

if (global.playerType == 'spectate') {
player.x = global.gameWidth / 2;
player.y = global.gameHeight / 2;
}

socket.emit('windowResized', { screenWidth: global.screenWidth, screenHeight: global.screenHeight });
}

0 comments on commit 8a1a8f4

Please sign in to comment.