Developing a rhythm game with LÖVE

Curious software engineer
Search for a command to run...

Curious software engineer
No comments yet. Be the first to comment.
Since last article, I worked on these two planned features Game Over screen with scoring and retry button Finalizing the notes balancing and rhythm But it’s not completely finalized yet, and will continue working on both. I thought though it would...
It’s the summer holidays, after all. So I wanted to spent some time with my 7 years old daughter to teach her programming. ⌨️ I spent some time before discussing with her some of the basics concept verbally: the different parts of a computer, and bas...

This article is a follow up on my previous one introducing the concept of SE Spectrum: https://sonny.alvesdi.as/a-better-way-to-discuss Existing solutions For long, the easiest way to run a spectrum was to use visual drawing or diagram tools like ...

Introduction to SE Spectrum

One of the greatest tool available on GitHub is Dependabot. For those not familiar with it, in short it's a bot reviewing your list of dependencies and proposing PRs to update them. https://docs.github.com/en/code-security/getting-started/dependabot-...

Photo by Harli Marten on Unsplash As long as I remember I have always been interested by skepticism. And I think one element that really resonated with me has been that conference talk by Phil Plait: https://www.youtube.com/watch?v=FrFRbGjUtJk 15 ...

Last week at the end of that article I mentioned that I was working on a game in order to explore LÖVE. That game is called Beathoven. It is a rhythm game based on the remix sound of the 5th symphony of Beethoven made Lionel Yu and Nicolas Chazarre.
Instead of using a piano like controller, I wanted to use something a bit more like those music arcade game with button spread around the screen.

And I went with 4 buttons spread as a diamond. 4 buttons means 4 fingers game play, which sounds not too overwhelming, but still fun.




It’s difficult to reduce multiple hours and several thousands lines of code in one blog article, so I’ll share a couple of things.
In order to save the notes currently on the track of a button, I made this Queue class (based on the classes.lua I shared in my last article.)
local classes = require "classes"
local Queue = classes.class()
function Queue:init()
self.first = 0
self.last = -1
self.items = {}
end
function Queue:count()
local count = 0
for _ in pairs(self.items) do count = count + 1 end
return count
end
function Queue:enqueue(value)
self.last = self.last + 1
self.items[self.last] = value
end
function Queue:dequeue()
if self:count() == 0 then
return nil
end
local first = self.first
local value = self.items[first]
self.items[first] = nil -- to allow garbage collection
self.first = self.first + 1
return value
end
function Queue:deleteFirst(value)
local i = -1
for k = self.first,self.last,1
do
if self.items[k] == value then
self.items[k] = nil
i = k
end
end
-- Value not found
if i == -1 then
return
end
for k = i,self.last,1
do
self.items[k] = self.items[k+1]
end
self.items[self.last] = nil
self.last = self.last - 1
end
function Queue:print()
local res = "Queue: { "
for k,v in pairs(self.items) do
res = res..k..": "..v..", "
end
print(res.." }")
end
return Queue
When I press a button, a note is dequeued, and we check if the note was overlapping the button. If it was, then it’s a success and if not, then it’s an early miss.
A rhythm game means playing with the rhythm/beat of a music.
In order to do that, I could think of several solutions:
I went with the latter, knowing that I would still have a lot of manually editing to do, to make things fun.
If you load a sound in audacity, you can click then on Analyze > Beat Finder

This will add a label track with a label on each beat detected. You can export it then File > Export > Export Labels. It’ll provide you a text format easily parsable.
If you were looking to making a rhythm game on your own, I hope that my findings can help you to get kick-started quickly. If you are interested in Beathoven and/or would like to participate in the dev, let me know. For now, the game is not open source, but once I am happy with the state of the code and game I’ll share it.