Difference between revisions of "Getting Started"

m (what version?)
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.
  
 +
You can inspect what Version of Löve you have installed like this:
 +
 +
<code>
 +
love --version
 +
</code>
 +
 +
== 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.
 +
 +
<source lang="lua">
 +
function love.draw()
 +
    love.graphics.print("Hello World", 400, 300)
 +
end
 +
</source>
 
== Running Games ==
 
== Running Games ==
  
LÖVE can load a game in two ways:  
+
LÖVE can load a game in two ways:
 
 
 
* From a folder.  
 
* From a folder.  
 
* From a .love file (a renamed .zip-file).
 
* From a .love file (a renamed .zip-file).
Line 12: Line 26:
 
In both cases, there has to be a file called <code>main.lua</code> in the root path. 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.  
 
In both cases, there has to be a file called <code>main.lua</code> in the root path. 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:
+
===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.
 +
There's also the [[Scite]] option.
  
<code>love mygame</code>
+
You can also call it from command line:
  
 
For instance:
 
For instance:
 
<pre>
 
<pre>
love /home/bob/mygame
 
love /home/bob/packagedgame.love
 
 
love C:\games\mygame
 
love C:\games\mygame
 
love C:\games\packagedgame.love
 
love C:\games\packagedgame.love
 
</pre>
 
</pre>
 
You can inspect the LÖVE version like this:
 
 
<code>
 
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.
 
On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.
Line 35: Line 44:
 
love --console
 
love --console
 
</code>
 
</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.
 
There's also the [[Scite]] option.
 
 
On Mac OSX, you can simple double-click a .love file to run it.
 
 
== 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.
 
 
<source lang="lua">
 
function love.draw()
 
    love.graphics.print("Hello World", 400, 300)
 
end
 
</source>
 
 
===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.
 
  
 
===Linux===
 
===Linux===
  
On Linux, you can use the command line. (Of course, you can use the command line in Windows too, if you prefer).
+
On Linux, you can use the command line:
  
<code>
+
<pre>
 
love /home/path/to/game
 
love /home/path/to/game
</code>
+
love /home/path/to/packagedgame.love
 +
</pre>
  
 
===Mac OSX===
 
===Mac OSX===
Line 85: Line 76:
 
love /home/path/to/game
 
love /home/path/to/game
 
</code>
 
</code>
 
+
 
== 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.

Revision as of 23:09, 11 July 2010

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.
  • From a .love file (a renamed .zip-file).

In both cases, there has to be a file called main.lua in the root path. 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.

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 command line:

For instance:

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

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 the command line:

love /home/path/to/game
love /home/path/to/packagedgame.love

Mac OSX

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

open -a love mygame

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 -a TextEdit ~/.bash_profile):

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

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

love /home/path/to/game

Next steps