Skip to content

Commit

Permalink
Added starting zoom-out transition effect when starting a game
Browse files Browse the repository at this point in the history
  • Loading branch information
Naviary2 committed Dec 14, 2024
1 parent a737b21 commit 0bc45cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/client/scripts/esm/game/chess/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import spritesheet from '../rendering/spritesheet.js';
import loadingscreen from '../gui/loadingscreen.js';
import movepiece from '../../chess/logic/movepiece.js';
import frametracker from '../rendering/frametracker.js';
import area from '../rendering/area.js';
// Import End

/**
Expand Down Expand Up @@ -248,6 +249,19 @@ async function loadGamefile(newGamefile) {
loadingscreen.close();
// Required so the first frame of the game & tiles is rendered once the animation page fades away
frametracker.onVisualChange();

startStartingTransition();
}

/**
* Sets the camera to the recentered position, plus a little zoomed in.
* THEN transitions to normal zoom.
*/
function startStartingTransition() {
const centerArea = area.calculateFromUnpaddedBox(gamefile.startSnapshot.box);
movement.setPositionToArea(centerArea);
movement.setBoardScale(movement.getBoardScale() * 1.75);
guinavigation.callback_Recenter();
}

/** The canvas will no longer render the current game */
Expand Down
1 change: 1 addition & 0 deletions src/client/scripts/esm/game/gui/guinavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,5 @@ export default {
lockRewind,
update,
isCoordinateActive,
callback_Recenter,
};
4 changes: 0 additions & 4 deletions src/client/scripts/esm/game/gui/guiplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Import Start
import websocket from '../websocket.js';
import guigameinfo from './guigameinfo.js';
import area from '../rendering/area.js';
import onlinegame from '../misc/onlinegame.js';
import localstorage from '../../util/localstorage.js';
import style from './style.js';
Expand Down Expand Up @@ -387,9 +386,6 @@ function loadGame(gameOptions) {
clockValues: gameOptions.clockValues
});
game.loadGamefile(newGamefile);

const centerArea = area.calculateFromUnpaddedBox(newGamefile.startSnapshot.box);
movement.setPositionToArea(centerArea);

options.setNavigationBar(true);
sound.playSound_gamestart();
Expand Down

0 comments on commit 0bc45cf

Please sign in to comment.