Love2d – Tutorial Part 0 | Hello Wörld

Prior to all game making we have the do the obligatory Hello World example for Love2d. We will also show you how to run a game and build a .love file. See the Getting Started section and the Love2d Tutorials on love2d.org for more advice.
 

Ready, Steady…?

Hopefully you found a suitable Text Editor for your system. For the duration of this tutorial series I will use Fraise on Mac OS X and Notepad++ on windows. If you want to know more about Text Editors see my post about editors on Mac OS X and the other post about editors on windows.

Hello World

1. Open your Texteditor, make a new file. Save it as main.lua in a directory called “tut0″. Main.lua will always be the first file that is executed/interpreted by love.

2. Type the following:

function love.draw() love.graphics.print(“hello world”, 100, 100) end

Drag the directory “tut0″ on the love.app or love.exe. This should be your result:

Hello Wörld

Tip: To speed things up in the future you can also use the terminal on Mac OS X:

  1. Open the Terminal
  2. Type: alias love=’/Applications/love.app/Contents/MacOS/love’
  3. Click on ‘Shell’ in the menubar, and then ‘Use Setting as Default’
  4. You  can now just type: love pathtodirectory, where pathtodirectory is your current project folder , e.g. /Users/me/love/tut0

On windows and especially with Notepad++ you can set up a keycombination that launches your current project. See the tutorial on windows editors on how to set that up.

Making a .love file

The great thing about .love files are that they launch directly with love(if love is properly installed on your system) and they are easily distributable. As I said .love files are basically renamed .zip files. So easiest steps to a .love file would be:

  1. Go INTO your current project folder.
  2. Select all the files and subfolders add them to a .zip file, for example to tut0.zip
  3. Rename the tut0.zip file to tut0.love, in the Mac OS X terminal this would be the command: mv tut0.zip tut0.love
  4. If you double click the resulting file it should be executed

The first step is very important. A common problem for beginners is that they put the whole folder in the .zip file. This will not work. The main.lua has to be in the root of the zip file!

In the next part of this series we will actually begin programming a game!

Love2d – What is Love? An Introduction
Love2d – Introduction: Installing/Choose a Texteditor on Windows
Love2d – Introduction: Installing/Choose Texteditor on OS X
Love2d – Tutorial Part 0 | Hello Wörld
Love2d – Tutorial Part 1 | Invaders must die!
Love2d – Tutorial Part 2 | Pew Pew!

One thought on “Love2d – Tutorial Part 0 | Hello Wörld

  1. Thanks for the tutorial!

    You may want to fix the hello world text though, right now the quotation marks are “ – a left double quotation mark, Unicode character U+201C – and ” – a right double quotation mark, Unicode character U+201D. They should be ” – a standard quotation mark, Unicode character U+0022.

    Running the code on your site verbatim will cause an error: http://i.imgur.com/01Rj0Dp.png

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment moderation is enabled. Your comment may take some time to appear.