HELLO WORLD
STEPS
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.
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.draw() love.graphics.print("Hello World", 400, 300) end
- Download and install Sublime Text editor
- Create a folder 'anywhere' on your PC
- Open the folder with Sublime
- Create a new file named "main.lua" inside the folder. (YES, the name has to be exactly main.lua)
- Paste the code and save the file.
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, 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 or running lovec.exe
(since 0.10.2)):
"C:\Program Files\LOVE\love.exe" --console
Simple Build System
Create a new Build System: Tools -> Build System -> New Build System
and use the following code.
{ "selector": "source.lua", "file_regex": "^Error: (?:[^:]+: )?([^: ]+?):(\\d+):() ([^:]*)$", "windows": { "cmd": ["C:/Program Files/LOVE/love.exe", "${folder:${file_path}}"], "shell": true }, "osx": { "cmd": ["/Applications/love.app/Contents/MacOS/love", "${folder:${file_path}}"] }, "linux": { "cmd": ["love", "${folder:${file_path}}"] } }
Save it in the suggested location as love-run.sublime-build
.
Now you can use Ctrl+B or Cmd+B to run your love project.
BONUS
- Install Package Control
Press Ctrl+Shift+P to open the command palette.
When you type just "package" you can see a list of suggestions, click on "Package Control: Install Package". This will install package control in your Sublime. - Enable Lua (Love) syntax highlighting
Press Ctrl+Shift+P to open the command palette.
When you type just "lua" you can see a list of suggestions, click on "Set Syntax: Lua (Love)". This will Lua Love package in your Sublime.
Comments
Post a Comment
Thanks for the comment! :)