How I created a beats per minute counter in Godot in 15 minutes

I mentioned that I was going to see how easily I can create a standard desktop app with Godot and it turns out the answer is "less than 15 minutes". As you can see, it doesn't look like much and it isn't very accurate, but it demonstrates just how quickly you can put something together.

I created a new Godot project and simply added:

  • A 2D Node
  • A Button
  • A Text Field

And then I added the following GD Script to the button:

extends Node2D
var timeStarted = null
var taps = 0
var timePassed = null
var bpm = 0 func _on_Button_button_down():
taps = taps + 1
if timeStarted == null:
timeStarted = OS.get_ticks_msec()
timePassed = OS.get_ticks_msec() - timeStarted
if timePassed > 0:
bpm = 60 / float(timePassed) * float(taps) * 1000
var out = "time Started: " + str(timeStarted) + "\n"
out += "Time passed: " + str(timePassed) + "\n"
out += "Taps: " + str(taps) + "\n"
out += "BPM: " + str(bpm) + "\n"
$MainOutput.text = out

It's not perfect and certainly not very accurate but I think it shows just how easy it is to throw together a basic app.

Share this Post

Leave a comment