Difference between revisions of "Getting Started"

(must is mustard, has to be has to be)
(Added note about adding love to PATH.)
 
(68 intermediate revisions by 26 users not shown)
Line 3: Line 3:
 
Download the latest version of LÖVE from [http://love2d.org/#download the website], and install it. If you're on Windows and don't want to ''install'' LÖVE, you can also just download the zipped executables and extract them anywhere.
 
Download the latest version of LÖVE from [http://love2d.org/#download the website], and install it. If you're on Windows and don't want to ''install'' LÖVE, you can also just download the zipped executables and extract them anywhere.
  
== Running Games ==
+
To find out which version of LÖVE is installed, run the following command:
  
LÖVE can load a game in two ways:
+
<source lang="bash">
 +
love --version
 +
</source>
  
* From a folder.
+
Note that you may need to add the directory where LÖVE resides to your system's PATH variable, in order to be able to run it from the command line.
* From a .love file (a renamed .zip-file).
 
 
In both cases, there has to be a file called <code>main.lua</code> on the root. This file will be loaded when LÖVE starts. If this file is missing, LÖVE will not recognize the folder or .love file as game, and you will be presented with the standard no-game screen.  
 
  
On the command line, you can use love like this:
+
== Making a Game ==
  
<code>love mygame</code>
+
To make a minimal game, create a folder anywhere, and open up your favorite text editor. [http://www.sublimetext.com Sublime Text] is a pretty good one for all operating systems, and it has Lua support built in. Create a new file in the folder you just created, and name it <code>main.lua</code>. Put the following code in the file, and save it.
  
For instance:
+
<source lang="lua">
<pre>
+
function love.draw()
love /home/bob/mygame
+
    love.graphics.print("Hello World", 400, 300)
love /home/bob/packagedgame.love
+
end
love C:\games\mygame
+
</source>
love C:\games\packagedgame.love
+
== Running Games ==
</pre>
 
  
You can inspect the version like this:
+
LÖVE can load a game in two ways:
 +
* From a folder that contains a main.lua file.
 +
* From a [[LÖVE Game File|.love file]] that has a main.lua file in the top-most directory level (aka root)
  
<code>
+
For creating .love files see [[Game Distribution]].
love --version
 
</code>
 
  
On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.
+
----
 +
===Windows===
  
<code>
+
[http://studio.zerobrane.com ZeroBrane Studio], [[Sublime Text]], [[Notepad++]], and [[SciTE]] allow you to launch the game from within their code editors.
love --console
 
</code>
 
  
If you are running Windows and you want an easy way to play your applications, you can create a shortcut to the LÖVE executable in the folder above your LÖVE game. When you want to try the game, just drag and drop the folder to the shortcut, and it will run.
+
Otherwise, the easiest way to run the game is to drag the folder onto either love.exe or a shortcut to love.exe. Remember to drag the folder containing <code>main.lua</code>, and not <code>main.lua</code> itself.
There's also the [[Scite]] option.
 
  
On Mac OSX, you can simple double-click a .love file to run it.
+
You can also launch the game from the command line:
  
== Making a Game ==
+
<source lang="powershell">
 +
"C:\Program Files\LOVE\love.exe" "C:\games\mygame"
 +
"C:\Program Files\LOVE\love.exe" "C:\games\packagedgame.love"
 +
</source>
  
To make a minimal game, create a folder anywhere, and open up your favorite code editor. Notepad++ is a pretty good one for Windows, and it has Lua support built in. Create a new file in the folder you just created, and name it main.lua. Put the following code in the file, and save it.
+
You can create a shortcut to do this; simply make a shortcut to love.exe, right-click on it and select "Properties", and then put the command line you want in the "Target" box for the shortcut.
  
<source lang="lua">
+
On Windows, there is a special command-line option which will attach a console to the window, allowing you to see the result of <code>print</code> calls (equivalent to setting <code>t.console=true</code> in [[conf.lua]] or running <code>lovec.exe</code> (since [[0.10.2]])):
function love.draw()
+
<source lang="bash">
    love.graphics.print("Hello World", 400, 300)
+
"C:\Program Files\LOVE\love.exe" --console
end
 
 
</source>
 
</source>
  
===Windows===
+
----
 +
 
 +
===Linux===
 +
 
 +
On Linux, you can use one of these command lines:
  
On Windows, the easiest way to run the game is to drag the folder onto love.exe, or a shortcut to love.exe. Remember to drag the folder containing <code>main.lua</code>, and not <code>main.lua</code> itself.
+
<source lang="bash">
 +
love /home/path/to/gamedir/
 +
love /home/path/to/packagedgame.love
 +
</source>
  
===Linux===
+
If you installed LÖVE system-wide, you can double click on .love files in your file manager as well.
  
On Linux, you can use the command line. (Of course, you can use the command line in Windows too, if you prefer).
+
----
 +
=== macOS ===
  
<code>
+
On macOS, a folder or .love file can be dropped onto the love application bundle. On the Mac Terminal (command line), you can use love like this (assuming it's installed to the Applications directory):
love /home/path/to/game
 
</code>
 
  
===Mac OSX===
+
<source lang="bash">open -n -a love "~/path/to/mygame"</source>
  
On Mac OSX, a folder or .love file can be dropped onto the Love.app application bundle. On the Mac OSX Terminal (commandline), you can use love like this (assuming it's installed to the Applications directory):
+
However, the above method will not output printed text to the terminal window. To do that, you will need to execute the love binary inside the application bundle directly:  
  
<code>open -a love mygame</code>
+
<source lang="bash">/Applications/love.app/Contents/MacOS/love ~/path/to/mygame</source>
  
In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:
+
You can set up an alias in your Terminal session to call the binary when you use <code>love</code> by adding an alias to your <code>~/.zshrc</code> file (Z shell configuration file).
  
<code>/Applications/love.app/Contents/MacOS/love mygame</code>
+
Open the file with
 +
<source lang="bash">open -a TextEdit ~/.zshrc</source>
  
You can setup an alias in your Terminal session to call the binary when you use <code>love</code> by adding an alias to your ~/.bash_profile (<code>open -a TextEdit ~/.bash_profile</code>):
+
You may have to run
 +
<source lang="bash">touch ~/.zshrc</source>
 +
first if the file does not yet exist.
  
<pre>
+
Then paste in the following code and save the file:
 +
<source lang="bash">
 
# alias to love
 
# alias to love
 
alias love="/Applications/love.app/Contents/MacOS/love"
 
alias love="/Applications/love.app/Contents/MacOS/love"
</pre>
+
</source>
  
Now you can call love from the commandline like Linux and Windows:
+
Now you can call love from the command line like Linux and Windows:
  
<code>
+
<source lang="bash">
love /home/path/to/game
+
love ~/path/to/mygame
</code>
+
</source>
 +
 
 +
if this doesn't works you should reload the .zshrc file like this:
 +
<source lang="bash">
 +
source ~/.zshrc
 +
</source>
 +
and try it again.
 +
 
 +
----
 +
=== Android ===
 +
As long as you have LÖVE for Android installed from the Play Store or another source and assume you didn't download/use the "embed" suffix flavor, the following methods will work:
 +
 
 +
* Transfer your game folder to <code>/sdcard/Android/data/org.love2d.android/files/games/lovegame</code> (<code>/sdcard/lovegame</code> also works in Pie and earlier) where <code>main.lua</code> is found at <code>/sdcard/Android/data/org.love2d.android/files/games/lovegame/main.lua</code>. In Android 11 or later, these directories only accessible through MTP in PC. Then run LÖVE for Android.
 +
 
 +
* Transfer/download a .love of your game to the device and click on it. Some file explorers will run the .love using LÖVE for Android. If it does not you can install ES File Explorer which will. If you use Dropbox, you can use that to open .love files. May not work in Android Nougat or later due to Android restrictions.
 +
 
 +
 
 +
If you have more questions, consider reading [https://github.com/love2d/love-android/wiki/FAQ---Frequently-Asked-Questions Android-specific FAQ]. If your question is not listed, then feel free to ask in the forums or the Discord.
 +
 
 +
----
 +
 
 +
 
 +
----
 +
=== iOS ===
 +
 
 +
In order to run LÖVE for iOS, it must first be compiled and installed. To do that, you’ll need macOS, [https://developer.apple.com/xcode/ Xcode 7 or newer], and the LÖVE for iOS source code downloadable from the [https://love2d.org home page].
 +
 
 +
* If the <code>libraries</code> folder isn't present in the <code>love/platform/xcode/ios</code> folder, download the iOS libraries from the [https://love2d.org/ homepage], and place the <code>iOS/libraries</code> folder from the zip there. They contain the third-party library dependencies used by LÖVE.
 +
 
 +
* Open the Xcode project found at <code>love/platform/xcode/love.xcodeproj</code> and select the <code>love-ios</code> target in the dropdown menu at the top of the window.
 +
 
 +
* You may want to change the Build Configuration from Debug to Release for better performance, by opening the "Edit Scheme..." menu from the same dropdown selection.
 +
 
 +
* Choose either an iOS Simulator device or your plugged-in iOS device in the dropdown selection to the right of the previous one, and click the Build-and-Run ▶︎ button to the left, which will install LÖVE on the target device after compiling it.
 +
 
 +
 
 +
LÖVE on iOS includes a simple list interface of games that are installed (until you [[Game Distribution|fuse]] a .love to it for distribution.)
 +
 
 +
* To put a .love file on the iOS Simulator after LÖVE is installed, drag the file onto the iOS Simulator’s window while it’s open. LÖVE will launch if it’s not running already. If another game is currently active you may need to quit LÖVE for the new game to show up (press Shift-Command-H twice to open the App Switcher menu on the iOS Simulator.)
 +
 
 +
* To put a .love file or game folder on your iOS device after LÖVE is installed, you can either download it with the Safari, or transfer it from your computer through iTunes when your device is connected: open iTunes, go to the iOS device which has LÖVE installed, go to the ‘Apps’ section and scroll down and find LÖVE, and add the .love file or game folder to LÖVE’s Documents section. On more recent iOS and Mac versions, you can use Airdrop to transfer your .love file from your Mac to where LÖVE is installed.
 +
 
 +
 
 +
See the [[Game Distribution]] page for creating Fused LÖVE games on iOS and distributing them.
 +
 
 +
 
 +
Note: for those interested in creating a LÖVE game directly on iOS, the Textastic app (available on the Apple App Store for purchase) can utilize SublimeText's packages-- one of which is a LÖVE package. You can follow these instructions to load that LÖVE package into the Textastic app on your iOS device to author LÖVE code directly on your iOS device. You'll then need to follow the earlier instructions on how to zip up that code into a .love file but then can either export that .love file to a LÖVE app running on your iOS device or an external device running a LÖVE application.
 +
 
 +
Instructions:
 +
 
 +
#Purchase the iOS Textastic app on the App Store
 +
# Create a folder in Textastic (while inside the Textastic app "Local Files" section  or in the iOS Files app under the Textastic folder) called "#Textastic"
 +
# go to https://github.com/szensk/subllualove in Safari on your iPad
 +
# tap the green "Code" button and select "Download ZIP"
 +
# Unzip the file in the Files app. This will create a folder called "subllualove-master"
 +
# Move or copy that folder into the folder "On my iPad/Textastic/#Textastic/". This is equivalent to this folder in Textastic: "Local Files/#Textastic/".
 +
# In Textastic, go to Settings (gear wheel on the bottom left portion of the app) -> Other and tap "Reload Customizations"
 +
# In File Properties (document looking icon on top right portion of the app) -> Syntax Definition, there is now a new item "LOVE (*.lua)" that you can select after opening a .lua file.
 +
 
 +
If you have any questions on this process, please contact the Textastic developer (very responsive by email support)
  
 
== Next steps ==
 
== Next steps ==
 
* [[Tutorial:Callback_Functions]] will teach you the basic structure of a love game.
 
* [[Tutorial:Callback_Functions]] will teach you the basic structure of a love game.
* [[:Category:Tutorials]] are the next piece of reading
+
* [[:Category:Tutorials]] are the next piece of reading.
 +
* [[Main Page|Wiki]] The LÖVE wiki.
 +
 
 +
== Other Languages ==
 +
{{i18n|Getting_Started}}
  
 
[[Category:LÖVE]]
 
[[Category:LÖVE]]

Latest revision as of 23:41, 20 October 2024

Get LÖVE

Download the latest version of LÖVE from the website, and install it. If you're on Windows and don't want to install LÖVE, you can also just download the zipped executables and extract them anywhere.

To find out which version of LÖVE is installed, run the following command:

love --version

Note that you may need to add the directory where LÖVE resides to your system's PATH variable, in order to be able to run it from the command line.

Making a Game

To make a minimal game, create a folder anywhere, and open up your favorite text editor. Sublime Text is a pretty good one for all operating systems, and it has Lua support built in. Create a new file in the folder you just created, and name it main.lua. Put the following code in the file, and save it.

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end

Running Games

LÖVE can load a game in two ways:

  • From a folder that contains a main.lua file.
  • From a .love file that has a main.lua file in the top-most directory level (aka root)

For creating .love files see Game Distribution.


Windows

ZeroBrane Studio, Sublime Text, Notepad++, and SciTE allow you to launch the game from within their code editors.

Otherwise, the easiest way to run the game is to drag the folder onto either love.exe or a shortcut to love.exe. Remember to drag the folder containing main.lua, and not main.lua itself.

You can also launch the game from the command line:

"C:\Program Files\LOVE\love.exe" "C:\games\mygame"
"C:\Program Files\LOVE\love.exe" "C:\games\packagedgame.love"

You can create a shortcut to do this; simply make a shortcut to love.exe, right-click on it and select "Properties", and then put the command line you want in the "Target" box for the shortcut.

On Windows, there is a special command-line option which will attach a console to the window, allowing you to see the result of print calls (equivalent to setting t.console=true in conf.lua or running lovec.exe (since 0.10.2)):

"C:\Program Files\LOVE\love.exe" --console

Linux

On Linux, you can use one of these command lines:

love /home/path/to/gamedir/
love /home/path/to/packagedgame.love

If you installed LÖVE system-wide, you can double click on .love files in your file manager as well.


macOS

On macOS, a folder or .love file can be dropped onto the love application bundle. On the Mac Terminal (command line), you can use love like this (assuming it's installed to the Applications directory):

open -n -a love "~/path/to/mygame"

However, the above method will not output printed text to the terminal window. To do that, you will need to execute the love binary inside the application bundle directly:

/Applications/love.app/Contents/MacOS/love ~/path/to/mygame

You can set up an alias in your Terminal session to call the binary when you use love by adding an alias to your ~/.zshrc file (Z shell configuration file).

Open the file with

open -a TextEdit ~/.zshrc

You may have to run

touch ~/.zshrc

first if the file does not yet exist.

Then paste in the following code and save the file:

# alias to love
alias love="/Applications/love.app/Contents/MacOS/love"

Now you can call love from the command line like Linux and Windows:

love ~/path/to/mygame

if this doesn't works you should reload the .zshrc file like this:

source ~/.zshrc

and try it again.


Android

As long as you have LÖVE for Android installed from the Play Store or another source and assume you didn't download/use the "embed" suffix flavor, the following methods will work:

  • Transfer your game folder to /sdcard/Android/data/org.love2d.android/files/games/lovegame (/sdcard/lovegame also works in Pie and earlier) where main.lua is found at /sdcard/Android/data/org.love2d.android/files/games/lovegame/main.lua. In Android 11 or later, these directories only accessible through MTP in PC. Then run LÖVE for Android.
  • Transfer/download a .love of your game to the device and click on it. Some file explorers will run the .love using LÖVE for Android. If it does not you can install ES File Explorer which will. If you use Dropbox, you can use that to open .love files. May not work in Android Nougat or later due to Android restrictions.


If you have more questions, consider reading Android-specific FAQ. If your question is not listed, then feel free to ask in the forums or the Discord.




iOS

In order to run LÖVE for iOS, it must first be compiled and installed. To do that, you’ll need macOS, Xcode 7 or newer, and the LÖVE for iOS source code downloadable from the home page.

  • If the libraries folder isn't present in the love/platform/xcode/ios folder, download the iOS libraries from the homepage, and place the iOS/libraries folder from the zip there. They contain the third-party library dependencies used by LÖVE.
  • Open the Xcode project found at love/platform/xcode/love.xcodeproj and select the love-ios target in the dropdown menu at the top of the window.
  • You may want to change the Build Configuration from Debug to Release for better performance, by opening the "Edit Scheme..." menu from the same dropdown selection.
  • Choose either an iOS Simulator device or your plugged-in iOS device in the dropdown selection to the right of the previous one, and click the Build-and-Run ▶︎ button to the left, which will install LÖVE on the target device after compiling it.


LÖVE on iOS includes a simple list interface of games that are installed (until you fuse a .love to it for distribution.)

  • To put a .love file on the iOS Simulator after LÖVE is installed, drag the file onto the iOS Simulator’s window while it’s open. LÖVE will launch if it’s not running already. If another game is currently active you may need to quit LÖVE for the new game to show up (press Shift-Command-H twice to open the App Switcher menu on the iOS Simulator.)
  • To put a .love file or game folder on your iOS device after LÖVE is installed, you can either download it with the Safari, or transfer it from your computer through iTunes when your device is connected: open iTunes, go to the iOS device which has LÖVE installed, go to the ‘Apps’ section and scroll down and find LÖVE, and add the .love file or game folder to LÖVE’s Documents section. On more recent iOS and Mac versions, you can use Airdrop to transfer your .love file from your Mac to where LÖVE is installed.


See the Game Distribution page for creating Fused LÖVE games on iOS and distributing them.


Note: for those interested in creating a LÖVE game directly on iOS, the Textastic app (available on the Apple App Store for purchase) can utilize SublimeText's packages-- one of which is a LÖVE package. You can follow these instructions to load that LÖVE package into the Textastic app on your iOS device to author LÖVE code directly on your iOS device. You'll then need to follow the earlier instructions on how to zip up that code into a .love file but then can either export that .love file to a LÖVE app running on your iOS device or an external device running a LÖVE application.

Instructions:

  1. Purchase the iOS Textastic app on the App Store
  2. Create a folder in Textastic (while inside the Textastic app "Local Files" section or in the iOS Files app under the Textastic folder) called "#Textastic"
  3. go to https://github.com/szensk/subllualove in Safari on your iPad
  4. tap the green "Code" button and select "Download ZIP"
  5. Unzip the file in the Files app. This will create a folder called "subllualove-master"
  6. Move or copy that folder into the folder "On my iPad/Textastic/#Textastic/". This is equivalent to this folder in Textastic: "Local Files/#Textastic/".
  7. In Textastic, go to Settings (gear wheel on the bottom left portion of the app) -> Other and tap "Reload Customizations"
  8. In File Properties (document looking icon on top right portion of the app) -> Syntax Definition, there is now a new item "LOVE (*.lua)" that you can select after opening a .lua file.

If you have any questions on this process, please contact the Textastic developer (very responsive by email support)

Next steps

Other Languages