What I like about Love2D
2020 November 29

I recently decided to revisit game development. I decided to use the Love2D engine, because the API is rather beautiful in it’s simplicity. The graphics are treated as a pixel buffer to which I can draw lines, squares and circles to. It has 2 core functions for me to work with, which I like. All in all, it reminds me a lot of QBasic, which I learned in high school. I’ll link to my repo at the end and provide appropriate links at the various points.

To start with Love2D we make create a main.lua file, and can run our game like this, love . after installing Love2D to our path. The love binary is in many distro’s repositories, see the appendix for a list, and how to install.

There are 2 functions that we override to implement our game.

This is where we put our main game loop. The dt parameter tells us how much time has passed. This helps with implementing a fixed update, since sometimes it takes longer to render stuff. So we can think of all of units of movement as a per second measurement. We could also pass the time parameter.
This is where we put our draw code. The screen is cleared before the draw code is executed. We can put whatever love.graphics.* calls here we want.

The Graphics in Love

I implemented my toy game using only circles and lines, but it supports sprites too. The fact that we can use lines and circles makes it a lot like QBasic. In QBasic you would use a series of line, and circle commands to do things to a pixel buffer, but the screen wouldn’t be cleared between every frame.

It’s also nice that we can render text very quickly and easily using love.graphics.print. In other game frameworks I would have to create a text field, and keep track of it. With this I just tell it where I want it to put this block of text. I know this is less efficient than just making a texture, but it’s nice for banging something together for a game jam. There’s a couple of useful overrides to do other things with the text too.


Lua is a little bit weird to the newcomer, but it’s very simple to pick up, and runs fast enough. The weirdness mostly comes from 1 indexing in lists, but that’s not really a big problem. We need to be more flexible in our thought processes anyways. Also there’s only a single container structure, the table, which is an associative array.

I find it very pleasant to write, if a bit weird. It’s very much a scripting language. If you want to use classes, you have to do some meta programming, which has some interesting effects on your code.

Also apparently using table.remove is not recommended, but it seems to work well enough. Apparently it’s rather slow, but I didn’t really notice any issues when I was using it (note: the top answer on StackOverflow is wrong. See this answer).

Conclusion and Comparison to other engines.

I feel this engine makes it really easy to put a game together very quickly. It includes some rather useful features to make games in the old way. It’s easier to use than some C++ engines I’ve used in the past. I like that it deals with the whole render loop, and comes with some very pleasant primitives. In the past, I’ve used SFML and SDL for some game and graphics development. They’re nice, but they require a lot more infrastructure to get started. It requires the setup of a compiler, and the associated infrastructure, you also need to get the libraries installed. Love is nice because it’s interpreted, and I can see my changes immediately, by invoking a single binary. All in all, I really like it, and will be doing some future work with it.

The game I mentioned at the beginning is a recreation of my very first game which was based on the Kongregate Shooterial. You can view my code here, as it was at the time of this post’s publication. I spent about 3 hours on it, so don’t expect a lot from it. It’s a see how fast I could put together a basic space shootem up. I plan on improving this code over time and eventually turn into a bullet hell kind of game.

The game being played


See the Building LOVE wiki page for details on how to install Love for your distro.

Remember you can also subscribe using RSS at the top of the page!

Share this on → Mastodon Twitter LinkedIn Reddit

A selected list of related posts that you might enjoy:

Written by Henry J Schmale on 2020 November 29
Hit Counter