Difference between revisions of "Love Game Engine"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Download)
(Getting Started)
Line 5: Line 5:
  
 
=Getting Started=
 
=Getting Started=
The main site for the Love engine includes a getting started page:
+
==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.
  
[https://love2d.org/wiki/Getting_Started Getting Started]
+
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:
 +
<syntaxhighlight lang=lua>
 +
function love.load()
 +
    -- use to set up your game
 +
end
 +
function love.draw()
 +
    love.graphics.print("Hello World", 400, 300)
 +
end
 +
</syntaxhighlight>
 +
 
 +
==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)
 +
 
 +
Within Windows ZeroBrane Studio, Sublime Text 2, 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):
 +
 
 +
"C:\Program Files\LOVE\love.exe" --console
  
 
=Tutorials=
 
=Tutorials=

Revision as of 08:42, 3 June 2019

Download

Go to the main site for the Love engine:

love2d.org

Getting Started

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.load()
    -- use to set up your game
end
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)

Within Windows ZeroBrane Studio, Sublime Text 2, 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):

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

Tutorials

Here is the link for the tutorial on the Love wiki site:

Love tutorials