Quick guide to learn how to install the open source LÖVE (Love2D) game engine framework on a Raspberry Pi, and a brief introduction to its use.
In this article, I will explain to you how to install the LÖVE framework on a Raspberry Pi 4/400 under Raspberry Pi OS.
What is LÖVE framework?
LÖVE is an open source cross-platform 2D video game development engine, which uses the LUA programming language.
The API provided by the framework gives access to the video and sound functions of the machine through the SDL and OpenGL libraries.
Easy to access, it is an ideal engine to start developing games and practice programming, plus it is perfectly compatible with the Raspberry Pi.
Installing the LÖVE framework on the Pi
For this guide you will need a Raspberry Pi 4, a keyboard & mouse (or ideally a Raspberry Pi 400), and the Raspberry Pi OS installed on the Micro SD inserted in your Pi.
Once the system is launched, open a terminal window.
Then enter the following command, to download package information from all configured sources and update them:
sudo apt-get update && sudo apt-get upgrade
Answer Y to the question: Do you want to continue? [Y/n]
Finally, enter the following command to install the LÖVE framework:
sudo apt-get install love
Once the installation of LÖVE is completed, you can check its version by typing in the terminal window :
Version 11.1 (Mysterious Mysteries) at the time of this article for the stable Raspberry Pi version.
Installation of the Visual Studio Code IDE
This step is optional, for example, you can use the Geany IDE already installed with the Raspberry Pi OS or the standard text editor.
I advise you to use VS Code to follow more easily the last chapter of this article. In addition, Visual Studio Code is a modern IDE that will give you access to some really handy extensions for programming with LÖVE.
To install VS Code on Raspberry Pi OS, nothing could be easier, click on the Raspberry logo in your taskbar and choose Preferences then click sure Recommended Software
VS Code can be found in the Programming list, just check the box to the right of it and click on the Apply button at the bottom of the window. You will find the program in the Programming list in your Raspberry Pi OS quick launch menu.
Installing the Love2D Support extension for VS Code
We are going to install an extension that will make it easier to develop with LÖVE.
Launch VS Code, then click on the Extensions button (Ctrl + Shift + x) on the left side menu, then type Love2D Support in the search bar at the top of the left side panel Extensions Marketplace.
Install the extension by clicking on the blue Install button
Once the extension is installed, you need to configure it by clicking on the little gear at the top below the title, and choose Extension Settings from the drop-down menu.
You must fill in the correct path to LÖVE for Linux, replacing the default path, which is the one for Windows platform (C:\Program Files\Love\love.exe) by :
You now have access, thanks to the extension, to the Intelissense for the LÖVE API (Code Completion), access to the online help when hovering the mouse cursor and a shortcut (Alt + L) to directly launch and test your code.
Creating your first program with LÖVE
To test if we have correctly installed LÖVE on the Raspberry Pi and correctly installed and configured Visual Studio Code, there is nothing better than to write your first program.
To start and to stay organized, I advise you to create, for example, a Love2d folder in your /home/pi/document/ folder
Inside this folder /home/pi/document/Love2d/ you will create another folder, which we will call HelloWorld for our first example project.
If VS Code is not running, it is time to open it and go to the File menu and click on Open Folder....
Point to the new folder you created /home/pi/document/Love2d/HelloWorld and select it.
You are now inside your folder, just create a new file by going to the File menu and click on New File (Ctrl + N) or by clicking on the little Page + icon in the left sidebar.
Create a file named main.lua, we'll type our first lines of code in it:
function love.draw() love.graphics.print("Hello World!", 100, 100) end
Save your file (Ctrl + S) and use the keyboard shortcut Alt + L to launch your first application in LÖVE, if everything goes as planned, you should see the window below:
In a future article, I'll cover the basics of programming with LÖVE, and we'll create a first mini-game together, to address some simple but essential concepts.
You are welcome to leave me a comment, if you found this article useful.