From f770e2fbf8c31c4bb08de84fe9cac5943d445e8a Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 14 Dec 2018 12:49:38 +1100 Subject: [PATCH] clean --- client/src/scenes/constants.js | 54 +++++++--------------------------- client/src/scenes/cryps.js | 18 +++++++----- 2 files changed, 20 insertions(+), 52 deletions(-) diff --git a/client/src/scenes/constants.js b/client/src/scenes/constants.js index 5bf77644..aabd6c39 100644 --- a/client/src/scenes/constants.js +++ b/client/src/scenes/constants.js @@ -1,60 +1,27 @@ // POSITIONING FNS // floors prevent subpixel rendering which looks trash -// const menuWidth = () => window.innerWidth; -// const menuHeight = () => Math.floor(window.innerHeight * 0.05); +const menuWidth = () => window.innerWidth; +const menuHeight = () => Math.floor(window.innerHeight * 0.05); -// const combatWidth = () => window.innerWidth; -// const combatHeight = () => window.innerHeight - menuHeight(); -// const combatY = () => menuHeight(); -// const combatX = () => 0; - -// const crypListWidth = () => Math.floor(window.innerWidth * 0.2); -// const crypListHeight = () => window.innerHeight - menuHeight(); -// const cryplistRowHeight = cryps => crypListHeight() / cryps.length; -// const crypListY = () => menuHeight(); -// const crypListX = () => 0; - -// const gameListWidth = () => Math.floor(window.innerWidth * 0.2); -// const gameListHeight = () => Math.floor(window.innerHeight / 10); -// const gameListX = () => crypListWidth(); -// const gameListY = i => menuHeight() + (gameListHeight() * i); -// const gameListRowY = i => menuHeight() + (gameListHeight() * (i + 2)); - -// const statsWidth = () => Math.floor(window.innerWidth - crypListWidth() - gameListWidth()); -// const statsHeight = () => window.innerHeight - menuHeight(); -// const statsY = () => menuHeight(); -// const statsX = () => crypListWidth() + gameListWidth(); -// const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); -// const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2); -// const statsTextMargin = () => 24; - -// const logWidth = () => combatWidth(); -// const logHeight = () => combatHeight() * 0.3; -// const logY = () => menuHeight() + (combatHeight() * 0.7); -// const logX = () => combatWidth() * 0.6; - -const menuWidth = () => 1600; -const menuHeight = () => 25; - -const combatWidth = () => 1600; -const combatHeight = () => 1000 - menuHeight(); +const combatWidth = () => window.innerWidth; +const combatHeight = () => window.innerHeight - menuHeight(); const combatY = () => menuHeight(); const combatX = () => 0; -const crypListWidth = () => Math.floor(1600 * 0.2); -const crypListHeight = () => 1000 - menuHeight(); +const crypListWidth = () => Math.floor(window.innerWidth * 0.2); +const crypListHeight = () => window.innerHeight - menuHeight(); const cryplistRowHeight = cryps => crypListHeight() / cryps.length; const crypListY = () => menuHeight(); const crypListX = () => 0; -const gameListWidth = () => Math.floor(1600 * 0.2); -const gameListHeight = () => Math.floor(1000 / 10); +const gameListWidth = () => Math.floor(window.innerWidth * 0.2); +const gameListHeight = () => Math.floor(window.innerHeight / 10); const gameListX = () => crypListWidth(); const gameListY = i => menuHeight() + (gameListHeight() * i); const gameListRowY = i => menuHeight() + (gameListHeight() * (i + 2)); -const statsWidth = () => Math.floor(1600 - crypListWidth() - gameListWidth()); -const statsHeight = () => 1000 - menuHeight(); +const statsWidth = () => Math.floor(window.innerWidth - crypListWidth() - gameListWidth()); +const statsHeight = () => window.innerHeight - menuHeight(); const statsY = () => menuHeight(); const statsX = () => crypListWidth() + gameListWidth(); const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); @@ -66,7 +33,6 @@ const logHeight = () => combatHeight() * 0.3; const logY = () => menuHeight() + (combatHeight() * 0.7); const logX = () => combatWidth() * 0.6; - module.exports = { TEXT: { NORMAL: { fontFamily: 'monospace', fontSize: 16, color: '#ffffff' }, diff --git a/client/src/scenes/cryps.js b/client/src/scenes/cryps.js index 2326ac96..66a7b8d2 100644 --- a/client/src/scenes/cryps.js +++ b/client/src/scenes/cryps.js @@ -8,9 +8,9 @@ function renderCryps() { type: Phaser.AUTO, backgroundColor: '#181818', resolution: window.devicePixelRatio, - antialias: true, - width: 1600, - height: 1000, + // antialias: true, + width: window.innerWidth, + height: window.innerHeight, physics: { default: 'arcade', arcade: { @@ -28,7 +28,7 @@ function renderCryps() { game.scene.sleep('Combat'); function resize() { - const canvas = document.querySelector("canvas"); + const canvas = document.querySelector('canvas'); if (!canvas) return false; @@ -37,12 +37,14 @@ function renderCryps() { const windowRatio = windowWidth / windowHeight; const gameRatio = game.config.width / game.config.height; if (windowRatio < gameRatio) { - canvas.style.width = windowWidth + "px"; - canvas.style.height = (windowWidth / gameRatio) + "px"; + canvas.style.width = `${windowWidth}px`; + canvas.style.height = `${(windowWidth / gameRatio)}px`; } else { - canvas.style.width = (windowHeight * gameRatio) + "px"; - canvas.style.height = windowHeight + "px"; + canvas.style.width = `${(windowHeight * gameRatio)}px`; + canvas.style.height = `${windowHeight}px`; } + + return true; } window.addEventListener('mouseup', () => game.registry.set('pan', false));