Difference between revisions of "Game Distribution"

(add love executor to the community tools list.)
m (Who the hell wants to install Android SDK just to distribute LÖVE game for Android?)
(27 intermediate revisions by 11 users not shown)
Line 4: Line 4:
  
 
* Windows → [[Game_Distribution#Creating_a_Windows_Executable|Windows Executable]]
 
* Windows → [[Game_Distribution#Creating_a_Windows_Executable|Windows Executable]]
* Mac OS X → [[Game_Distribution#Creating_a_MacOS_X_App|OS X Application]]
+
* Mac OS X → [[Game_Distribution#Creating_a_Mac_OS_X_Application|OS X Application]]
* Linux → plain .love file
+
* Linux → plain .love file, or [[Game_Distribution#Distribution_for_Linux|Appimages]]
 +
 
 +
__TOC__
  
 
== Create a .love-file ==
 
== Create a .love-file ==
Line 17: Line 19:
 
     <somedir>\SuperGame\conf.lua
 
     <somedir>\SuperGame\conf.lua
  
You must ensure the zip file containts
+
then you must ensure the zip file contains
  
 
     gfx\character.png
 
     gfx\character.png
Line 26: Line 28:
  
 
Once you have your zip file you simply rename the ending from .zip to .love and you are done!
 
Once you have your zip file you simply rename the ending from .zip to .love and you are done!
 +
 +
If you're using a case-insensitive file system (e.g. Windows), it's advisable to move the .love file to some place other than the folder where your game is, and test again. This will reveal any case sensitivity problems that other users may run into when trying to run your game. If it's run in the same folder, it will find there the files that it can't find in the .love file, so you have to move it before testing. A good place to move it is a folder within your game directory, e.g. <code>love/MyGame.love</code>.
  
 
=== Platform Specific Notes ===
 
=== Platform Specific Notes ===
Line 31: Line 35:
 
==== Windows ====
 
==== Windows ====
  
Windows supports creation of zip files out of the box. For detailed instructions see http://windows.microsoft.com/en-hk/windows-vista/compress-and-uncompress-files-zip-files
+
Windows supports creation of zip files out of the box via right-click menu. For detailed instructions see [https://support.microsoft.com/en-us/help/14200/windows-compress-uncompress-zip-files Compress and uncompress files (zip files)].
 +
 
 +
==== Mac OS X ====
  
==== Linux / OS X ====
+
Inside the game folder, select the game files and folders, right-click/Ctrl+click and pick '''Compress n items'''. Then rename the resulting <code>.zip</code> file to have a <code>.love</code> ending.
 +
 
 +
Alternatively, you can use the terminal. Navigate inside the game folder and run:
 +
 
 +
    zip -9 -r SuperGame.love .
 +
 
 +
==== Linux ====
  
 
Assuming your current directory is <tt style="font-size:1.3em">SuperGame/</tt> you can create the .love file from command line directly using
 
Assuming your current directory is <tt style="font-size:1.3em">SuperGame/</tt> you can create the .love file from command line directly using
  
     zip -9 -q -r SuperGame.love .
+
     zip -9 -r SuperGame.love .
  
 
== Creating a Windows Executable ==
 
== Creating a Windows Executable ==
Line 66: Line 78:
  
 
This method creates a '''fused''' game.
 
This method creates a '''fused''' game.
 +
 +
===== Windows icon =====
 +
 +
You can use your own icon images using tools like for example the freeware [http://www.angusj.com/resourcehacker/ Resource Hacker].
 +
 +
[https://youtu.be/WTk_HJdXVNQ?t=2m22s Video tutorial] and [http://gamedev.stackexchange.com/a/121947/9093 step-by-step instructions] are available.
  
 
==== Linux / OS X ====
 
==== Linux / OS X ====
Line 71: Line 89:
 
You can create the windows executable from Linux and OS X using the command line.
 
You can create the windows executable from Linux and OS X using the command line.
  
First download the official zipped 32 or 64 bit executable ('''not''' the installer) from [https://www.love2d.org/ https://www.love2d.org/].
+
First download the official zipped 32 or 64 bit executable ('''not''' the installer) from [https://www.love2d.org/ https://www.love2d.org/]. 32 bit games can run on 64bit Windows systems but not vice versa, so to save time on smaller games, you can provide 32bit only.
  
 
Then in the command line/terminal run
 
Then in the command line/terminal run
Line 87: Line 105:
 
* SuperGame.exe
 
* SuperGame.exe
 
* license.txt (note: the license '''requires''' that it be included in any further distribution)
 
* license.txt (note: the license '''requires''' that it be included in any further distribution)
* DevIL.dll
 
 
* love.dll
 
* love.dll
 
* lua51.dll
 
* lua51.dll
 
* mpg123.dll
 
* mpg123.dll
* msvcp110.dll
+
* msvcp120.dll
* msvcr110.dll
+
* msvcr120.dll
  
 
== Creating a Mac OS X Application ==
 
== Creating a Mac OS X Application ==
  
Once you have your game prepared as .love file you can make your game available for Mac OS X users using the official LÖVE zipped download for Mac from [https://www.love2d.org https://www.love2d.org].
+
Once you have your game prepared as .love file you can make your game available for Mac OS X users by following the steps below ([https://youtu.be/SU2RpGdezP4 video tutorial] available):
  
These are the steps required:
+
# Download and extract the Mac version of LÖVE from [https://www.love2d.org the LÖVE homepage]
 +
# Rename <tt>love.app</tt> to <tt>SuperGame.app</tt>
 +
# Copy your <tt>SuperGame.love</tt> to <tt>SuperGame.app/Contents/Resources/</tt> (right-click/Ctrl+click and pick "Show Package Content" on OS X). This will result in the game running in fused mode.
 +
# Modify <tt>SuperGame.app/Contents/Info.plist</tt> (see below for details)
 +
# Zip the <tt>SuperGame.app</tt> folder (e.g. to SuperGame_osx.zip) and distribute it. Enable the ''-y'' flag of zip to keep the symlinks.
  
# Download and unpack the Mac version of LÖVE from [https://www.love2d.org https://www.love2d.org]
+
When modifying <tt>SuperGame.app/Contents/Info.plist</tt> make sure to change the string values of the following XML-tags:
# Rename love.app to SuperGame.app
 
# Copy your SuperGame.love to SuperGame.app/Contents/Resources/
 
# Modify SuperGame.app/Contents/Info.plist
 
# Zip the SuperGame.app folder (e.g. to SuperGame_osx.zip) and distribute it. Enable the ''-y'' flag of zip to keep the symlinks.
 
 
 
When modifying the file SuperGame.app/Contents/Info.plist make sure to change the values of the following XML-tags:
 
  
 
* <tt>CFBundleIdentifier</tt>
 
* <tt>CFBundleIdentifier</tt>
Line 116: Line 131:
 
!width="300"|Original Info.plist
 
!width="300"|Original Info.plist
 
!width="300"|Modified Info.plist
 
!width="300"|Modified Info.plist
|-
+
|- style="vertical-align: top;"
 
|
 
|
 
     ...
 
     ...
 
     <key>CFBundleIdentifier</key>
 
     <key>CFBundleIdentifier</key>
     <string>org.love2d.love</string>
+
     <string>'''org.love2d.love'''</string>
 
     ...
 
     ...
 
     <key>CFBundleName</key>
 
     <key>CFBundleName</key>
     <string>LÖVE</string>
+
     <string>'''LÖVE'''</string>
 
     ...
 
     ...
 
     <key>NSPrincipalClass</key>
 
     <key>NSPrincipalClass</key>
 
     <string>NSApplication</string>
 
     <string>NSApplication</string>
     <key>UTExportedTypeDeclarations</key>
+
     '''<key>UTExportedTypeDeclarations</key>'''
     <array>
+
     '''<array>'''
     ...
+
     '''...'''
     </array>
+
     '''</array>'''
 
     </dict>
 
     </dict>
 
     </plist>
 
     </plist>
Line 153: Line 168:
 
<source lang="bash">love SuperGame.love</source>
 
<source lang="bash">love SuperGame.love</source>
  
A common mistake is to use the following method to make binaries for Linux;
+
Make sure to include a [[Config Files|<code>conf.lua</code> file]] with at least the LÖVE version used.
 +
<source lang="lua">
 +
function love.conf(t)
 +
    t.version = "0.10.1"
 +
end
 +
</source>
 +
 
 +
A common mistake is trying to fuse the love Linux binary with a love file:
  
 
<source lang="bash">
 
<source lang="bash">
Line 161: Line 183:
  
 
Please keep in mind, while the binary `SuperGame` will run on your machine, and other Linux distros that have the same architecture and similar version libraries, there's a good chance that '''it will not run on many other Linux distros'''.
 
Please keep in mind, while the binary `SuperGame` will run on your machine, and other Linux distros that have the same architecture and similar version libraries, there's a good chance that '''it will not run on many other Linux distros'''.
 +
 +
==== Debian ====
 +
 +
There is a policy for including LÖVE games in the Debian archive. It can be followed to create a package for a game even if it is not intended to include it in the archive.
 +
 +
[https://wiki.debian.org/Games/Love2d Packaging Love2d]
 +
 +
==== AppImages ====
 +
The AppImage format is a format for packaging applications in a way that allows them to run on a variety of different target systems (base operating systems, distributions) without further modification. The whole kit can be downloaded from [https://github.com/probonopd/AppImageKit/ here].
 +
 +
In order to package games using AppImage, the libraries and dependencies required by love need to be gathered, which can be done easily using [https://github.com/proot-me/PRoot/blob/master/doc/care/manual.txt CARE] (available packaged in the Ubuntu repositories) by executing:
 +
 +
<source lang='text'>care -o love.tar.gz love</source>.
 +
 +
This program makes an archive, which contains the love executable and its dependencies and related files kept in the way of your system.
 +
Secondly, the game's .love file needs to be 'fused' by the means shown in the above section. Now, the files need to be placed in the following way in a new directory:
 +
<source lang='text'>
 +
  Application Directory/
 +
  |
 +
  |--usr/
 +
  |  |
 +
  |  |-bin/ --> Your fused binary needs to be placed here
 +
  |  |-lib/ --> Your libraries need to be placed here
 +
  |  |-share/ --> Your (or love's) data files (and other things) need to be placed here, if any
 +
  |  |-...
 +
  |  -
 +
  |--<game name>.desktop --> This file contains path to the program's icon file, the name of the program and the command to execute it.
 +
  |--<game name>.png --> Your game's icon
 +
  -
 +
</source>
 +
Finally, the directory needs to be converted into an AppImage, using AppImageAssistant available in the kit.
 +
More information can be found in the [https://github.com/probonopd/AppImageKit/wiki AppImage Wiki].
  
 
== Android ==
 
== Android ==
 +
=== Compiling from source ===
 +
Firstly clone the android LÖVE project:
 +
<source lang='text'> git clone https://bitbucket.org/MartinFelis/love-android-sdl2 </source>
 +
Then, download the Android SDK and NDK (currently only compatible with [https://developer.android.com/ndk/downloads/older_releases.html ndk 14b or less]). And put a file called local.properties in the root path of project with the content (replacing ... by the local corresponding) :
 +
<source lang='text'>
 +
ndk.dir=...
 +
sdk.dir=...
 +
</source>
 +
Put the game (game.love) in the directory (project)/app/src/main/assets (if this directory don't exist create it).
 +
 +
And finally to generate the apk, do:
 +
<source lang='text'>
 +
./gradlew build
 +
</source>
 +
To Linux/macOS systems can be necessary run before: chmod +x gradlew
  
See the [https://bitbucket.org/MartinFelis/love-android-sdl2/wiki/Home Android wiki].
+
The apk will be in (project)/app/build/outputs/apk/
 +
 
 +
For more information see the [https://bitbucket.org/MartinFelis/love-android-sdl2/wiki/Home Android wiki].
 +
 
 +
=== Using APKTool ===
 +
Please see [[Game Distribution/APKTool]] for more information.
  
 
== iOS ==
 
== iOS ==
  
TODO (https://love2d.org/forums/viewtopic.php?f=12&t=76985)
+
Basic instructions for iOS (without fusing) are available at [[Getting_Started#iOS]].
 +
 
 +
To '''fuse''' your game into the LÖVE engine:
 +
# Get iOS source code from [http://love2d.org love2d.org].
 +
# Open platform/xcode/love.xcodeproj with Xcode.
 +
# Select love-ios target (not love-macosx)
 +
# Select '''Build Phases''' of the 'love-ios' target and add your 'game.love' file into '''Copy Bundle Resources'''.
 +
# Build the project.
 +
# Your game should appear on your iOS device as an app.
 +
 
 +
If you can't find the relevant XCode UI elements, you can refer to [https://youtu.be/MsYanwcU42E video tutorial on YouTube].
  
 
== Distribution on the web ==
 
== Distribution on the web ==
  
* [https://github.com/rnlf/motor Motor2d]
+
Publishing as a HTML5 or JavaScript game is possible thanks to [https://github.com/TannerRogalsky/love.js TannerRogalsky/love.js]. Threads for example are not supported though and playback of course depends on the browser.
* [https://love2d.org/forums/viewtopic.php?f=5&t=8487 Love2d-WebPlayer]
 
  
 
== Community Tools ==
 
== Community Tools ==
Line 179: Line 262:
 
There are a few tools developed by the community to help with game distribution.
 
There are a few tools developed by the community to help with game distribution.
 
* [https://github.com/MisterDA/love-release love-release] ([https://love2d.org/forums/viewtopic.php?t=75387 forum]), a Lua script that automates game distribution. Supports Windows, Mac OS X, Debian, Linux, with much more features.
 
* [https://github.com/MisterDA/love-release love-release] ([https://love2d.org/forums/viewtopic.php?t=75387 forum]), a Lua script that automates game distribution. Supports Windows, Mac OS X, Debian, Linux, with much more features.
* [https://love2d.org/forums/viewtopic.php?f=3&t=81409 LÖVE Executor], an online tool for making .exes.
 
* [https://stackmachine.com/ StackMachine] ([https://love2d.org/forums/viewtopic.php?f=5&t=76651 forum]), an online tool. Supports Windows and Mac OS X, ships with automatic updates and crash reports.
 
 
* [https://love2d.org/forums/viewtopic.php?f=3&t=80565 Love Distrubution Pack][sic], a windows-only tool that can create .love files and exes.
 
* [https://love2d.org/forums/viewtopic.php?f=3&t=80565 Love Distrubution Pack][sic], a windows-only tool that can create .love files and exes.
* [https://www.love2d.org/forums/viewtopic.php?f=5&t=30259 love-dist], a windows-only tool that can luac your files and create an exe.
+
* [https://www.love2d.org/forums/viewtopic.php?f=5&t=30259 love-dist], a windows-only tool that can [[LuaC]] your files and create an exe.
  
 
[[Category:LÖVE]]
 
[[Category:LÖVE]]

Revision as of 04:01, 10 April 2018

Once you have completed your game you surely want to make it available to others. In general you should first create a .love-file which can be either directly distributed (which requires users to have LÖVE installed) or used for platform specific packages.

These are the preferred ways to distribute your game depending on target (all make use of the .love file):

Create a .love-file

Please note that some operating systems use case-sensitive paths. To avoid unnecessary hassle make sure that the path specifications you use in code matches that of your folders and files.

To create a .love-file you have to create a zip file of the whole game directory. Make sure that your main.lua is in the root of the archive, e.g. if you have

   <somedir>\SuperGame\gfx\character.png
   <somedir>\SuperGame\main.lua
   <somedir>\SuperGame\conf.lua

then you must ensure the zip file contains

   gfx\character.png
   main.lua
   conf.lua

and not the directory SuperGame\.

Once you have your zip file you simply rename the ending from .zip to .love and you are done!

If you're using a case-insensitive file system (e.g. Windows), it's advisable to move the .love file to some place other than the folder where your game is, and test again. This will reveal any case sensitivity problems that other users may run into when trying to run your game. If it's run in the same folder, it will find there the files that it can't find in the .love file, so you have to move it before testing. A good place to move it is a folder within your game directory, e.g. love/MyGame.love.

Platform Specific Notes

Windows

Windows supports creation of zip files out of the box via right-click menu. For detailed instructions see Compress and uncompress files (zip files).

Mac OS X

Inside the game folder, select the game files and folders, right-click/Ctrl+click and pick Compress n items. Then rename the resulting .zip file to have a .love ending.

Alternatively, you can use the terminal. Navigate inside the game folder and run:

   zip -9 -r SuperGame.love .

Linux

Assuming your current directory is SuperGame/ you can create the .love file from command line directly using

   zip -9 -r SuperGame.love .

Creating a Windows Executable

Once you have packed your game into a .love file you can create a game executable that directly runs your game.

For this you have to append your .love file to the love.exe file that comes with the official LÖVE .zip file. The resulting file is your game executable.

Once you have your game executable you can pack it together with all the other DLL files of the official LÖVE .zip file into a new .zip file and share this with the world.

Note: Some people do not have a 64-bit version of Windows, so it is a good idea to either distribute both 32- and 64-bit versions of your game, or only distribute a 32-bit version.

Platform Specific Instructions

Windows

To create your game executable under windows use the command line to run

   copy /b love.exe+SuperGame.love SuperGame.exe

Note: You may have to run the command as an administrator on your computer. You can do this by going to Windows\System32 and right clicking on cmd.exe and selecting the option Run as administrator. After this, you must type cd C:\Program Files\LOVE\ (or whatever your default love directory is), then you may continue as normal.

Alternatively you can create a .bat (e.g. create_game_exe.bat) file with the contents

   copy /b love.exe+%1 "%~n1.exe"

and then you can simply drag your SuperGame.love file onto the .bat file and it will create the file SuperGame.love.exe which you could then use for distribution.

This method creates a fused game.

Windows icon

You can use your own icon images using tools like for example the freeware Resource Hacker.

Video tutorial and step-by-step instructions are available.

Linux / OS X

You can create the windows executable from Linux and OS X using the command line.

First download the official zipped 32 or 64 bit executable (not the installer) from https://www.love2d.org/. 32 bit games can run on 64bit Windows systems but not vice versa, so to save time on smaller games, you can provide 32bit only.

Then in the command line/terminal run

   cat love.exe SuperGame.love > SuperGame.exe

to obtain the game executable SuperGame.exe.


When distributing the windows executable you will need to include the dll files that came in the folder of the love.exe you used (so don't mix the 32 bit dll's with the 64 bit dll's). Without these files you will get error message when attempting to run SuperGame.exe on a windows machine.

The contents of your final distribution folder should look something like this:

  • SDL2.dll
  • OpenAL32.dll (note: this file is different in the 64 bit download despite still being called 'OpenAL32.dll')
  • SuperGame.exe
  • license.txt (note: the license requires that it be included in any further distribution)
  • love.dll
  • lua51.dll
  • mpg123.dll
  • msvcp120.dll
  • msvcr120.dll

Creating a Mac OS X Application

Once you have your game prepared as .love file you can make your game available for Mac OS X users by following the steps below (video tutorial available):

  1. Download and extract the Mac version of LÖVE from the LÖVE homepage
  2. Rename love.app to SuperGame.app
  3. Copy your SuperGame.love to SuperGame.app/Contents/Resources/ (right-click/Ctrl+click and pick "Show Package Content" on OS X). This will result in the game running in fused mode.
  4. Modify SuperGame.app/Contents/Info.plist (see below for details)
  5. Zip the SuperGame.app folder (e.g. to SuperGame_osx.zip) and distribute it. Enable the -y flag of zip to keep the symlinks.

When modifying SuperGame.app/Contents/Info.plist make sure to change the string values of the following XML-tags:

  • CFBundleIdentifier
  • CFBundleName

and remove the section UTExportedTypeDeclarations which ensures that Mac OS does not associate all .love files with your app. Overall the changes should be something like this:

Original Info.plist Modified Info.plist
   ...
   <key>CFBundleIdentifier</key>
   <string>org.love2d.love</string>
   ...
   <key>CFBundleName</key>
   <string>LÖVE</string>
   ...
   <key>NSPrincipalClass</key>
   <string>NSApplication</string>
   <key>UTExportedTypeDeclarations</key>
   <array>
   ...
   </array>
   </dict>
   </plist>
   ...
   <key>CFBundleIdentifier</key>
   <string>com.SuperCompany.SuperGame</string>
   ...
   <key>CFBundleName</key>
   <string>SuperGame</string>
   ...
   <key>NSPrincipalClass</key>
   <string>NSApplication</string>
   </dict>
   </plist>

Distribution for Linux

For Linux there is not yet a simple way to distribute your game. The general approach here is to point to the official LÖVE packages at https://www.love2d.org. Once the package is installed, the .love packages are usually automatically executed using the installed LÖVE package or using the command line:

love SuperGame.love

Make sure to include a conf.lua file with at least the LÖVE version used.

function love.conf(t)
    t.version = "0.10.1"
end

A common mistake is trying to fuse the love Linux binary with a love file:

cat /usr/bin/love SuperGame.love > SuperGame
chmod a+x ./SuperGame

Please keep in mind, while the binary `SuperGame` will run on your machine, and other Linux distros that have the same architecture and similar version libraries, there's a good chance that it will not run on many other Linux distros.

Debian

There is a policy for including LÖVE games in the Debian archive. It can be followed to create a package for a game even if it is not intended to include it in the archive.

Packaging Love2d

AppImages

The AppImage format is a format for packaging applications in a way that allows them to run on a variety of different target systems (base operating systems, distributions) without further modification. The whole kit can be downloaded from here.

In order to package games using AppImage, the libraries and dependencies required by love need to be gathered, which can be done easily using CARE (available packaged in the Ubuntu repositories) by executing:

care -o love.tar.gz love

.

This program makes an archive, which contains the love executable and its dependencies and related files kept in the way of your system. Secondly, the game's .love file needs to be 'fused' by the means shown in the above section. Now, the files need to be placed in the following way in a new directory:

  Application Directory/
  |
  |--usr/
  |   |
  |   |-bin/ --> Your fused binary needs to be placed here
  |   |-lib/ --> Your libraries need to be placed here
  |   |-share/ --> Your (or love's) data files (and other things) need to be placed here, if any
  |   |-...
  |   -
  |--<game name>.desktop --> This file contains path to the program's icon file, the name of the program and the command to execute it.
  |--<game name>.png --> Your game's icon
  -

Finally, the directory needs to be converted into an AppImage, using AppImageAssistant available in the kit. More information can be found in the AppImage Wiki.

Android

Compiling from source

Firstly clone the android LÖVE project:

 git clone https://bitbucket.org/MartinFelis/love-android-sdl2

Then, download the Android SDK and NDK (currently only compatible with ndk 14b or less). And put a file called local.properties in the root path of project with the content (replacing ... by the local corresponding) :

ndk.dir=... 
sdk.dir=...

Put the game (game.love) in the directory (project)/app/src/main/assets (if this directory don't exist create it).

And finally to generate the apk, do:

./gradlew build

To Linux/macOS systems can be necessary run before: chmod +x gradlew

The apk will be in (project)/app/build/outputs/apk/

For more information see the Android wiki.

Using APKTool

Please see Game Distribution/APKTool for more information.

iOS

Basic instructions for iOS (without fusing) are available at Getting_Started#iOS.

To fuse your game into the LÖVE engine:

  1. Get iOS source code from love2d.org.
  2. Open platform/xcode/love.xcodeproj with Xcode.
  3. Select love-ios target (not love-macosx)
  4. Select Build Phases of the 'love-ios' target and add your 'game.love' file into Copy Bundle Resources.
  5. Build the project.
  6. Your game should appear on your iOS device as an app.

If you can't find the relevant XCode UI elements, you can refer to video tutorial on YouTube.

Distribution on the web

Publishing as a HTML5 or JavaScript game is possible thanks to TannerRogalsky/love.js. Threads for example are not supported though and playback of course depends on the browser.

Community Tools

There are a few tools developed by the community to help with game distribution.

  • love-release (forum), a Lua script that automates game distribution. Supports Windows, Mac OS X, Debian, Linux, with much more features.
  • Love Distrubution Pack[sic], a windows-only tool that can create .love files and exes.
  • love-dist, a windows-only tool that can LuaC your files and create an exe.

Other Languages