use CODING AND ALGORITHMS to calculates notes per second
This commit is contained in:
Barinade 2021-05-11 18:01:02 -05:00
parent ebfb7fb5b6
commit dab9064aa2

View File

@ -1717,20 +1717,22 @@ class PlayState extends MusicBeatState
#end #end
if (currentFrames == FlxG.save.data.fpsCap) // reverse iterate to remove oldest notes first and not invalidate the iteration
// stop iteration as soon as a note is not removed
// all notes should be kept in the correct order and this is optimal, safe to do every frame/update
{ {
for(i in 0...notesHitArray.length) var balls = notesHitArray.length-1;
while (balls >= 0)
{ {
var cock:Date = notesHitArray[i]; var cock:Date = notesHitArray[balls];
if (cock != null) if (cock != null && cock.getTime() + 1000 < Date.now().getTime())
if (cock.getTime() + 2000 < Date.now().getTime()) notesHitArray.remove(cock);
notesHitArray.remove(cock); else
balls = 0;
balls--;
} }
nps = Math.floor(notesHitArray.length / 2); nps = notesHitArray.length;
currentFrames = 0;
} }
else
currentFrames++;
if (FlxG.keys.justPressed.NINE) if (FlxG.keys.justPressed.NINE)
{ {
@ -3046,8 +3048,10 @@ class PlayState extends MusicBeatState
note.rating = Ratings.CalculateRating(noteDiff); note.rating = Ratings.CalculateRating(noteDiff);
// add newest note to front of notesHitArray
// the oldest notes are at the end and are removed first
if (!note.isSustainNote) if (!note.isSustainNote)
notesHitArray.push(Date.now()); notesHitArray.unshift(Date.now());
if (!resetMashViolation && mashViolations >= 1) if (!resetMashViolation && mashViolations >= 1)
mashViolations--; mashViolations--;