Difference between revisions of "Getting Started"

(redundant cleanup, general linux install, scite separated, the screenshot was horrible from the start what was i thinking, moved making love files to mostly just a link)
(Cleaned up the 'running games' section a bit)
Line 29: Line 29:
 
===Windows===
 
===Windows===
  
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.
+
[http://studio.zerobrane.com ZeroBrane Studio], [[Sublime Text 2]], and [[SciTE]] allow you to launch the game from within their code editors.
  
[[SciTE]] allows you to launch the game from within the editor.
+
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.
  
 
You can also launch the game from the command line:
 
You can also launch the game from the command line:
  
 
<source lang="powershell">
 
<source lang="powershell">
love C:\games\mygame
+
"C:\Program Files\LOVE\love.exe" "C:\games\mygame"
love C:\games\packagedgame.love
+
"C:\Program Files\LOVE\love.exe" "C:\games\packagedgame.love"
 
</source>
 
</source>
  
 
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.
 
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 option which will attach a console to the window, allowing you to see standard output:
+
On Windows, there is a special command-line option which will attach a console to the window, allowing you to see standard output:
 
<source lang="bash">
 
<source lang="bash">
love --console
+
"C:\Program Files\LOVE\love.exe" --console
 
</source>
 
</source>
  
Line 58: Line 58:
 
If you installed LÖVE system-wide, you can double click on .love files in your file manager as well.
 
If you installed LÖVE system-wide, you can double click on .love files in your file manager as well.
  
===Mac OSX Snow Leopard (10.6) or earlier ===
+
===Mac OS X ===
  
On Mac OSX, a folder or .love file can be dropped onto the Love.app application bundle. On the Mac OSX Terminal (command line), you can use love like this (assuming it's installed to the Applications directory):
+
On Mac OS X, 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):
  
<source lang="bash">open -n -a love "/home/path/to/game"</source>
+
<source lang="bash">open -n -a 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:
+
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:  
  
<source lang="bash">/Applications/love.app/Contents/MacOS/love mygame</source>
+
<source lang="bash">/Applications/love.app/Contents/MacOS/love ~/path/to/mygame</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 <code>~/.bash_profile</code>.
+
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>~/.bash_profile</code>.
  
 
Open the file with
 
Open the file with
Line 86: Line 86:
  
 
<source lang="bash">
 
<source lang="bash">
love "/home/path/to/game"
+
love "~/path/to/mygame"
</source>
 
 
 
If you debug using the print command, it is useful to see this printed in realtime. In which case the following will open an extra window that will show the printed text.
 
 
 
<source lang="bash">
 
xterm -e /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
 
</source>
 
 
 
===Mac OSX Lion (10.7) or later ===
 
 
 
In order to run LÖVE and retain the print() functionality in Lion, you can use a script such as the following:
 
 
 
<source lang="bash">
 
#!/bin/bash
 
exec /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
 
 
</source>
 
</source>
  

Revision as of 03:33, 13 February 2014

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

Making a Game

To make a minimal game, create a folder anywhere, and open up your favorite text 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.

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 2, 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 standard output:

"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.

Mac OS X

On Mac OS X, 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 ~/.bash_profile.

Open the file with

open -a TextEdit ~/.bash_profile

You may have to run

touch ~/.bash_profile

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"

Next steps

Other Languages