/love-game

Primary LanguageLuaMIT LicenseMIT

LOVE VSCode Game Template

A fully configured VSCode template for LOVE

Features

Prerequisites

LÖVE and Makelove should be in your PATH environment variable.

Setup

1 - Use this template to create a new repository for your game, then clone that repository locally.
Create with template

2 - Open the Workspace.code-workspace file with Visual Studio Code. You will be prompted that there are recommended extensions and if you want to install these. Click 'Install'.
If this does not happen, install Sumneko's Lua extension, Local Lua Debugger and Editorconfig manually.

3 - Configure the Game/conf.lua and Tools/build/makelove.toml with the settings specific for your game.
NOTE: Make sure to keep t.console set to false in love.confg. Local Lua Debugger will not work otherwise.

4 - Configure the Root/.editorconfig to your liking for code styles.

5 - Change the Root/LICENSE file to your liking and/or swap out my name for your name.

In case you need help, feel free to send me (Keyslam) a message in the LÖVE Discord server. There's also a bunch of other cool people there who are always willing to help.

Running

Press F5 to launch the game in 'Debug mode'. In debug mode you can use breakpoints and inspect variables. This does have some performance impact though.
You can switch to 'Release mode' in the 'Run and Debug' tab (Ctrl+Shift+D).
Alternatively, you can run lovec game in the terminal, but you will have debugging capabilities.

Structure

├── /Game
│   ├── /assets         Contains the game's assets
│   ├── /lib            Contains external libraries
│   └── /src            Contains the game's source code
│
├── Tools
│   ├── /build          Contains the makelove.toml
│   └── package.json    Contains all scripts to use with NPM Scripts
│
├── Resources           Contains resources for you game that should not be shipped, like raw audio
│
├── Builds              Contains the builds of your game made with makelove
│
└── Root                Root access to the workspace

Appendix A: Why isn't Pixelbyte Studio's "Love2D support" extension included?

Pixelbyte Studio's "Love2D support" extension is commonly used by beginners because it is the first result that shows up when you search for LÖVE extensions in VSCode. However, it doesn't add any features you can't get with a well configured VSCode workspace. It also doesn't work with Local Lua Debugger and gives conflicting Intellisense results with the Lua Language Server.

Appendix B: Setting up a minimal project yourself.

Sometimes you don't want a full blown template and just get the minimum required settings to get your editor working. The following steps will explain how to setup a project with the Sumneko Language Server and a launch task:

  1. Create a folder for your game with your main.lua and conf.lua.

  2. Open the folder with VSCode.

  3. Install the Sumneko Lua Language Server and Local Lua Debugger extensions.

  4. In the same folder as your main.lua, create a folder named .vscode

  5. In the .vscode folder, create a file named settings.json and copy the following contents into it:

{
	"Lua.workspace.library": [
		"${3rd}/love2d/library",
		"lib"
	],
	"Lua.runtime.version": "LuaJIT",
	"Lua.workspace.checkThirdParty": false,
}
  1. In the .vscode folder, create a file named launch.json and copy the following contents into it:
{
	"version": "0.2.0",
	"configurations": [
		{
			"type": "lua-local",
			"request": "launch",
			"name": "Release",
			"program": {
				"command": "love"
			},
			"args": [
				".",
			],
		},
	]
}

You can use this template as a basis for how to add additional features such as debugging, code styles, folder structures, automatic builds, et cetera.