Add NPS(MAX) function, click to reset individual stats.

This commit is contained in:
Wiwi Kuan 2023-03-30 00:48:51 +08:00 committed by GitHub
parent f77e81ec6c
commit 7d3cde5a53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View file

@ -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

View file

@ -30,7 +30,7 @@
<!-- Our sketch will go here! -->
</div>
<span style="font-size: 11px;">
TIME使用時間 | NOTE COUNT總彈奏音符數 | NOTES/S最近一秒鐘彈奏音符數 | LEGATO圓滑指數最近一秒鐘平均來說有幾個鍵被同時按住 <br />
TIME使用時間 | NOTE COUNT總彈奏音符數 | NPS最近一秒鐘彈奏音符數括號為歷史最大值 | LEGATO圓滑指數最近一秒鐘平均來說有幾個鍵被同時按住 <br />
CALORIES消耗熱量估計值好玩就好| KEYS現在正在被按住或被踏板留住的音 | PEDALS左右踏板深度顯示 <br />
(密技:點鍵盤最左上角的角落,可以儲存截圖) <br /><br />
</span>

View file

@ -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);
}