I'm coding a microbit game for a school assignment and decided to ripoff Friday Night Funkin, which is a game where you have to play a song as accurately as possible. I've tried to code in this accuracy in my ripoff by getting more points the more accurate you are. The problem is there is a small pause between each note, and the pause is noticeably longer if you don't press the button to "play" the note.
Original Example Code:
basic.show_leds("""
. . # . .
. . . . #
# . . . .
# . . . .
. . . . #
""")
Timer_3_Accuracy(300)
Overall_Timer(300)
Original Function Code:
def Overall_Pause(num: number):
global Overall_Timer
basic.pause(num - Overall_Timer)
Overall_Timer = 0
def Timer_3_Accuracy(num: number):
global Timer_Three, Overall_Timer, Score
while not (input.pin_is_pressed(TouchPin.P2)):
basic.pause(1)
Timer_Three += 1
Overall_Timer += 1
if input.pin_is_pressed(TouchPin.P2) or Overall_Timer == num:
break
if Timer_Three <= 125:
Score += 50
elif Timer_Three > 125 and Timer_Three <= num:
Score += 30
Timer_Three = 0
I then simplified it so there wouldn't be as many functions because I thought was a processing power issue but it hasn't changed anything. I just added this to the accuracy function and took out the Overall_Pause function:
basic.pause(num - Overall_Timer)
Overall_Timer = 0
Does anyone have any recommendations? What am I doing wrong here? Would I need to reconfigure the while not function so it isn't as redundant?
Thanks in advance
EDIT: A related question, how would/is there a way to measure two accuracy points at once if your song has two "notes" at the same time?