From 7d3cde5a53df8425b731817123f8a90b1d00ed02 Mon Sep 17 00:00:00 2001 From: Wiwi Kuan Date: Thu, 30 Mar 2023 00:48:51 +0800 Subject: [PATCH] Add NPS(MAX) function, click to reset individual stats. --- globals.js | 1 + index.html | 2 +- piano-visualizer.js | 29 +++++++++++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/globals.js b/globals.js index 46ee49a..7ff13a0 100644 --- a/globals.js +++ b/globals.js @@ -28,6 +28,7 @@ let notesThisFrame = 0; let totalNotesPlayed = 0; let shortTermTotal = new Array(60).fill(0); let legatoHistory = new Array(60).fill(0); +let notesSMax = 0; let totalIntensityScore = 0; // for key pressed counter diff --git a/index.html b/index.html index 8bb7dae..9d13f07 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,7 @@ - TIME:使用時間 | NOTE COUNT:總彈奏音符數 | NOTES/S:最近一秒鐘彈奏音符數 | LEGATO:圓滑指數(最近一秒鐘平均來說有幾個鍵被同時按住)
+ TIME:使用時間 | NOTE COUNT:總彈奏音符數 | NPS:最近一秒鐘彈奏音符數(括號為歷史最大值) | LEGATO:圓滑指數(最近一秒鐘平均來說有幾個鍵被同時按住)
CALORIES:消耗熱量(估計值,好玩就好)| KEYS:現在正在被按住或被踏板留住的音 | PEDALS:左右踏板深度顯示
(密技:點鍵盤最左上角的角落,可以儲存截圖)

diff --git a/piano-visualizer.js b/piano-visualizer.js index fd98e92..9805ea1 100644 --- a/piano-visualizer.js +++ b/piano-visualizer.js @@ -117,7 +117,7 @@ function drawTexts() { // NOTES let notesText = "NOTE COUNT" + "\n" + totalNotesPlayed; - text(notesText, 95, 79); + text(notesText, 85, 79); // CALORIES let caloriesText = "CALORIES" + "\n" + (totalIntensityScore/250).toFixed(3); // 250 Intensity = 1 kcal. @@ -125,14 +125,15 @@ function drawTexts() { // SHORT-TERM DENSITY let shortTermDensity = shortTermTotal.reduce((accumulator, currentValue) => accumulator + currentValue, 0); // Sum the array. - let shortTermDensityText = "NOTES/S" + "\n" + shortTermDensity; - text(shortTermDensityText, 200, 79); + if (shortTermDensity > notesSMax) { notesSMax = shortTermDensity }; + let shortTermDensityText = "NPS(MAX)" + "\n" + shortTermDensity + " (" + notesSMax + ")"; + text(shortTermDensityText, 190, 79); // LEGATO SCORE let legatoScore = legatoHistory.reduce((accumulator, currentValue) => accumulator + currentValue, 0) legatoScore /= 60; let legatoText = "LEGATO" + "\n" + legatoScore.toFixed(2); - text(legatoText, 280, 79); + text(legatoText, 276, 79); // NOW PLAYING let nowPlayingText = "KEYS" + "\n" + truncateString(getPressedKeys(), 47); @@ -143,8 +144,6 @@ function pushHistories() { shortTermTotal.push(notesThisFrame); shortTermTotal.shift(); notesThisFrame = 0; - - legatoHistory.push(isKeyOn.reduce((accumulator, currentValue) => accumulator + currentValue, 0)); legatoHistory.shift(); @@ -219,4 +218,22 @@ function mouseClicked() { if (mouseX < 50 && mouseY < 50) { saveCanvas('nicechord-pianometer', 'png'); } + if (mouseY > 76) { + if (mouseX <= 84) { + sessionStartTime = new Date(); + } + + if (mouseX > 84 && mouseX < 170) { + totalNotesPlayed = 0; + } + + if (mouseX > 187 && mouseX < 257) { + notesSMax = 0; + } + + if (mouseX > 347 && mouseX < 420) { + totalIntensityScore = 0; // RESET CALORIES + } + } + console.log(mouseX, mouseY); } \ No newline at end of file