Go through the previous two posts if this is your first time getting started with LOVE2D.
After creating my first game with LOVE2D, i wanted to create an executable file, like we always do with games. And we can share that executable (.exe) file with our friends who can then play the game, without downloading the LOVE2D engine or Sublime text editor.
I love that LOVE2D has so many options for Game distribution. You can distribute your game for the following platforms.
- Windows
- macOS
- Linux
- Android
- iOS
- Web
LÖVE Game File
LÖVE game files or .love files are games, packaged for the LÖVE engine.
The file format is the same as a Zip file format with a ".love" file name ending instead of ".zip".
LÖVE game files contain the main.lua at the top-most directory level of the Zip archive script and other assets (e.g. fonts, images, music, scripts, sounds, etc.).
Lets start by talking about how runnable 'lovechives' work: When
love.exe
starts up, it first checks its own name, if its called something other thanlove
orlove.exe
it immediately checks to see if there is something stuck to its end. if there is, then it tries to interpret it as if it were a 'lovechive'.So basically, we want to stick a zip-file to love's bottom
- by Textmode
Let's find love.exe in your computer. It is located inside the folder where LOVE2D was installed (in your very first step). Mine is located in the default location.: C:\Program Files\LOVE>
So you can see love.exe and some other files inside the LOVE folder. Double-click to open love.exe.
Create .love File
It is a simple process. But I passed my whole day trying to do this. I misunderstood that when it said "create zip file", it meant any kind of archive file. So I created a .RAR archive. And that didn't work. Finally figured out that I'm supposed to make a .ZIP file exactly.
- Go inside your game folder.
Here, my game folder is flapbox. And it has only one content right now - main.lua - Create zip archive of the contents of folder.
- Select the contents of your game folder.
- Right click on the selection to see the options. Click on "Add to archive" .
Make sure you select ZIP. And rename the archive name to any_name.love. You file can have any name, but MUST have .love extension.
REMEMBER! You're supposed to archive the contents of the folder, not the folder flapbox itself. - Is a .love file created?
- Open the love file.
Opening up the love file should open up the game. If it doesn't open. you won't be able to make the executable file.
Create .exe File
- Open up your Command Line. You may have to run the command as an administrator on your computer. There are many ways to do this though.
In Windows 10, I just search CMD and then run it as an administrator. - In command line, go to the LOVE2D folder. Mine is located in the default location.: C:\Program Files\LOVE>
If you are unsure how to do this, you can take help from this article. - Open up this LOVE folder in File Explorer.
- Copy the .love file (mine is flapbox.love) that you previously created and paste it in the LOVE folder that you opened above.
- Now go back to your command line. And run the following command.
copy /b love.exe+flapbox.love flapbox.exe
Here, flapbox.love is your .love file's name. And flapbox.exe is the name of the exe file that will be created.
PS: If you want to learn more about the copy /b command that we used, read here. - Check your LOVE folder. There will be an exe file created with the name you wrote above.
Double-click to run the exe file and check it.
This should open up your own game instead of the default love.exe animation we saw previously.
Distributing the Executable
- Go to the LOVE folder where your .exe file was created.
- Select the necessary files and add them into an archive. (JAR or ZIP or any archive)
The important files are : your .exe file and the dll files. Other files like changes.txt, readme.txt etc are optional. You can edit these text files according to your need. - Rename your archive file and move it somewhere else.
- Now you can just send this archive file to your friends or upload in some platforms for sharing. All they will have to do is --> Extract the file --> Run the .exe file.
- To make sure, check yourself too. Extract the archive and run the .exe file.
- Run the exe file to play the game.
Comments
Post a Comment
Thanks for the comment! :)