diff --git a/assets/i18n/EN.json b/assets/i18n/EN.json index c8d98ce..5475712 100644 --- a/assets/i18n/EN.json +++ b/assets/i18n/EN.json @@ -13,6 +13,7 @@ "GAME OVER": "GAME OVER", "SCORE": "SCORE", + "SCOREBOARD": "SCOREBOARD", "CPM": "CPM", "MODE": "MODE", diff --git a/assets/i18n/RU.json b/assets/i18n/RU.json index ef11540..6ed8ca6 100644 --- a/assets/i18n/RU.json +++ b/assets/i18n/RU.json @@ -13,6 +13,7 @@ "GAME OVER": "ИГРА ОКОНЧЕНА", "SCORE": "СЧЕТ", + "SCOREBOARD": "ТАБЛО", "CPM": "СВМ", "MODE": "РЕЖИМ", diff --git a/cs.js b/cs.js index c65cd61..d2f8fbe 100644 --- a/cs.js +++ b/cs.js @@ -51,6 +51,9 @@ CSGame.setStateFromMenu = function () { this.MENU_ITEM = 0; return this.setState(this.STATES.OPTIONS_STATE); } + case 2: { + return this.setState(this.STATES.SCOREBOARD_STATE); + } } }; // Restart diff --git a/helpers/draw-menu.helper.js b/helpers/draw-menu.helper.js index 806b488..fe71027 100644 --- a/helpers/draw-menu.helper.js +++ b/helpers/draw-menu.helper.js @@ -1,9 +1,8 @@ export function drawMenu(menu, selectedId) { this.ctx.save(); - this.ctx.font = "italic " + this.ctx.font; menu.forEach((item, id) => { this.ctx.beginPath(); - this.ctx.fillText(`${selectedId === id ? ">" : ""} ${item} ${selectedId === id ? "<" : ""}`, this.widthCenter, this.heightCenter - (16 * 1.4 * 1 - 8 * 1.4 * menu.length % 2) + 16 * 1.4 * id); + this.ctx.fillText(`${selectedId === id ? ">" : ""} ${item} ${selectedId === id ? "<" : ""}`, this.widthCenter, this.heightCenter - (16 * 1.4 * menu.length / 2) + 16 * 1.4 * id + 8 * 1.4); }) this.ctx.closePath(); this.ctx.restore(); diff --git a/helpers/index.js b/helpers/index.js index e841b22..715c4f5 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -1,3 +1,4 @@ export * from "./nop.helper.js"; export * from "./draw-menu.helper.js"; export * from "./settings.helper.js"; +export * from "./random-with-except.helper.js" diff --git a/helpers/random-with-except.helper.js b/helpers/random-with-except.helper.js new file mode 100644 index 0000000..7627adf --- /dev/null +++ b/helpers/random-with-except.helper.js @@ -0,0 +1,15 @@ +export function randomCharWithExcept(chars, except) { + let result = chars[Math.floor(Math.random() * chars.length)]; + if (result === except) { + result = randomCharWithExcept(chars, except); + } + return result; +} + +export function randomWithExcept(to, except) { + let result = Math.floor(Math.random() * to + 1); + if (result === except) { + result = randomCharWithExcept(to, except); + } + return result; +} diff --git a/helpers/settings.helper.js b/helpers/settings.helper.js index 021b29b..3a72aa2 100644 --- a/helpers/settings.helper.js +++ b/helpers/settings.helper.js @@ -21,6 +21,23 @@ export const SETTINGS = { obj.SCORE = 0; break; } + case 'SCOREBOARD': { + obj.SCOREBOARD = [ + [ + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0] + ], + [ + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0] + ], + [ + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0] + ] + ]; + break; + } case 'LANG': { obj.LANG = 0; break; diff --git a/index.html b/index.html index e9353cc..2f09175 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,6 @@