LÖVE

Follow these steps to quickly set up and start using Planetary Processing with your LÖVE game. For more detailed information on both the SDK and the server-side API, please visit our documentation.

LÖVE Version

The Planetary Processing SDK depends on https calls for securely encrypted authentication with our servers, as such we only support LÖVE version 12.

Currently LÖVE version 12 is in pre-release state and can only be downloaded directly from the automatic builds on the LÖVE GitHub repo.

  1. Navigate to the 'Actions' tab of the LÖVE GitHub repo.

  2. Select the most recent workflow with a green tick and the 'main' tag.

  3. Choose your OS from the main.yml section.

  4. Scroll down the timeline to the 'Artifacts' tab.

  5. Download the pre-release version from the 'Artifact download URL' link.

Create a Planetary Processing Game

  1. Click Create Game in the top right

  2. Provide the details of your game. Upon its creation, you will be taken to your Game Dashboard.

  3. For this quick start, we will be using Anonymous Auth, which allows players to connect without a username and password. To enable this, navigate to the settings section of your Game Dashboard and enable Anonymous Auth as the Player Authentication Type within Game Settings.

Clone your Game Repository

  1. Clone the git repository as listed in your game dashboard - this is your Planetary Processing backend code.

git clone https://git.planetaryprocessing.io/git/*your-game*

Setting Up Your LÖVE Project

  1. Firstly you'll need to setup a new LÖVE project with at least a main.lua file, then you'll need to clone the Planetary Processing SDK. To do this you can clone it from our GitHub repository by running the following command from the same directory as your main.lua:

git clone https://github.com/planetary-processing/love2d-sdk sdk
  1. Then from within your main.lua you can require the sdk with:

local sdk = require("sdk.sdk")

This creates the sdk object which can be used to interact with Planetary Processing.

  1. Then you must, within love.load, call sdk.init(gameid, [username, password]) (username and password are not required in this example as we are using anonymous auth) as well as sdk.join(). You must also include a call to sdk.update() within love.update. So at a bare minimum your main.lua should look like:

local sdk = require("sdk.sdk")

function love.load()
  sdk.init(gameid)
  sdk.join()
end

function love.update(dt)
  sdk.update()
end
  1. Now that you have completed these steps, SDK will keep an up-to-date snapshot of the entities visible to the connected player in sdk.entities.

Entities are stored as tables which follow the format in the LÖVE SDK documentation.

  1. Try using the entities to draw something to the screen within love.draw, for example:

function love.draw()
  for id,entity in pairs(sdk.entities) do
    --draw entity
  end
end
  1. You can use sdk.message(msg) to send a message to the player entity on the backend, try it perhaps by sending a message to move the player.

Editing Your Backend Code

Using the repo we cloned earlier you can edit the behaviour of entities by changing their Lua file within the entity directory.

You can also change how many and what entities are spawned in the init.lua file.

We recommend experimenting here to get a sense of what you can do with Planetary Processing.

As a suggestion, you could change entity/player.lua to take the message sent in the previous section to perform some action or move around!

Push Your Planetary Processing Backend Code to the Game Repository

  1. After configuring your game entities and logic, push your changes to the game repository:

git add .
git commit -m "Configure game entities and logic for Planetary Processing"
git push

Deploy Latest Version in the Web UI

  1. Go back to your game dashboard in our web panel

  2. From the actions menu in the top right, select "Deploy Latest Version" - this will roll out your updated server-side code.

Start Game in the Web UI

  1. Click "Start Game" to begin your server-side simulation.

Play Your Multiplayer Game!

  1. Launch your LÖVE project.

  2. Connect to the multiplayer game through the game client, authenticate, and enjoy playing with others!

Last updated