Difference between revisions of "Getting Started"

m (Improved formatting on bash_profile section)
(more structure and readability for command examples)
Line 5: Line 5:
 
You can inspect what version of LÖVE you have installed like this:
 
You can inspect what version of LÖVE you have installed like this:
  
<code>
+
<source lang="bash">
 
love --version
 
love --version
</code>
+
</source>
  
 
== Making a Game ==
 
== Making a Game ==
Line 34: Line 34:
  
 
For instance:
 
For instance:
<pre>
+
<source lang="powershell">
 
love C:\games\mygame
 
love C:\games\mygame
 
love C:\games\packagedgame.love
 
love C:\games\packagedgame.love
</pre>
+
</source>
  
 
You can also 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.  Double-clicking the shortcut will execute the given command line.
 
You can also 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.  Double-clicking the shortcut will execute the given command line.
Line 43: Line 43:
 
On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.
 
On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.
  
<code>
+
<source lang="bash">
 
love --console
 
love --console
</code>
+
</source>
  
 
===Linux===
 
===Linux===
Line 51: Line 51:
 
On Linux, you can use one of these command lines:
 
On Linux, you can use one of these command lines:
  
<pre>
+
<source lang="bash">
 
love /home/path/to/gamedir/
 
love /home/path/to/gamedir/
 
love /home/path/to/packagedgame.love
 
love /home/path/to/packagedgame.love
</pre>
+
</source>
  
 
If you have installed the .deb, you can double click on .love files in your file manager as well.
 
If you have installed the .deb, you can double click on .love files in your file manager as well.
  
===Mac OSX===
+
===Mac OSX Snow Leopard (10.6) or earlier ===
  
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):
+
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):
  
<code>open -n -a love "/home/path/to/game"</code>
+
<source lang="bash">open -n -a love "/home/path/to/game"</source>
  
 
In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:
 
In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:
  
<code>/Applications/love.app/Contents/MacOS/love mygame</code>
+
<source lang="bash">/Applications/love.app/Contents/MacOS/love 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 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>.
+
Open the file with
 +
<source lang="bash">open -a TextEdit ~/.bash_profile</source>
  
Open the file with <code>open -a TextEdit ~/.bash_profile</code> (you may have to run <code>touch ~/.bash_profile</code> first if the file does not yet exist)
+
You may have to run
 +
<source lang="bash">touch ~/.bash_profile</source>
 +
first if the file does not yet exist.
  
 
Then paste in the following code and save the file:
 
Then paste in the following code and save the file:
<pre>
+
<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 "/home/path/to/game"
</code>
+
</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.
 
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.
  
<code>
+
<source lang="bash">
 
xterm -e /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
 
xterm -e /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
</code>
+
</source>
 +
 
 +
===Mac OSX Lion (10.7) or later ===
  
''Note for OS X Lion Users:'' The above steps do not achieve the desires results under Lion. In order to run Löve and retain the print() functionality you can use a script such as the following:
+
In order to run LÖVE and retain the print() functionality in Lion, you can use a script such as the following:
  
<pre>
+
<source lang="bash">
 
#!/bin/bash
 
#!/bin/bash
 
exec /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
 
exec /Applications/love.app/Contents/MacOS/love "/home/path/to/game"
</pre>
+
</source>
 
 
  
 
== Next steps ==
 
== Next steps ==

Revision as of 19:26, 17 December 2013

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.

You can inspect what version of LÖVE you have installed like this:

love --version

Making a Game

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.

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. The startup path specifies this folder.
  • From a .love file (a renamed .zip-file). The startup path specifies the file.

In both cases, there has to be a file called main.lua in the startup path or .love zipfile. 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 it will complain about a wrongly packaged game. A frequently made mistake is zipping the folder rather than its contents. This stems from very old practice (because when you unzip a folder you don't want it to splash out all over your current directory), but for LÖVE doing that doesn't make sense: you need to zip the game folder's contents only, to get a correct .love.

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 main.lua, and not main.lua itself. There's also the Scite option.

You can also call it from the command line:

For instance:

love C:\games\mygame
love C:\games\packagedgame.love

You can also 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. Double-clicking the shortcut will execute the given command line.

On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.

love --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 have installed the .deb, you can double click on .love files in your file manager as well.

Mac OSX Snow Leopard (10.6) or earlier

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):

open -n -a love "/home/path/to/game"

In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:

/Applications/love.app/Contents/MacOS/love mygame

You can setup 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 "/home/path/to/game"

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.

xterm -e /Applications/love.app/Contents/MacOS/love "/home/path/to/game"

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:

#!/bin/bash
exec /Applications/love.app/Contents/MacOS/love "/home/path/to/game"

Next steps

Other Languages