LogoLogo
  • Introduction
  • sdks
    • Feature Comparison
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Quick Start
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Server Side
    • Entities
    • Chunks
    • Dimensions
    • Events
    • Logging
    • Lua Environment
    • Git Primer
    • Physics
  • HTTP API
    • Authentication
    • Player API
  • Api Reference
    • Entity API
      • Create
      • Message
    • Client API
      • Message
    • Dimension API
      • Create
      • Delete
      • List
    • Events API
      • on_player_join
      • on_player_leave
    • Table API
      • Append
      • Remove
      • Join
    • Util API
      • Time
      • TimeMillis
    • HTTP Request API
      • Get
      • Post
      • Put
      • Delete
    • Physics API
      • NewBody
      • NewBoxShape
      • NewSphereShape
Powered by GitBook
On this page
  • LÖVE Version
  • Create a Planetary Processing Game
  • Clone your Game Repository
  • Setting Up Your LÖVE Project
  • Connecting to your game server
  • Creating Entities
  • Test your connection
  • Syncing the World Map and Window Origin
  • Syncing the World Map and Window Axis
  • Syncing the World Map and Window Scale
  • Player Movement
  • Follow Player Movement
  • Resizing Your Window (Optional)
  • Editing Your Backend Code
  • Push Your Planetary Processing Backend Code to the Game Repository
  • Deploy Latest Version in the Web UI
  • Start Game in the Web UI
  • Play Your Multiplayer Game!
  • Troubleshooting
  1. Quick Start

LÖVE

PreviousDefoldNextUnreal

Last updated 21 days ago

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 .

LÖVE Version

We recommend using LÖVE's most recent release version. If you are using an older version, we recommend a minimum of 11.0 for a successful integration.

Create a Planetary Processing Game

  1. Navigate to the

  2. Click Create Game in the top right

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

  4. 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

git clone https://git.planetaryprocessing.io/git/aBcDE/my-planetary-processing-game.git

Setting Up Your LÖVE Project

In a separate directory, set up a new LÖVE project with at least a main.lua file.

  1. Save an empty text document as main.lua, in your chosen directory.

git clone https://github.com/planetary-processing/love2d-sdk sdk
  1. Save a conf.lua file in the same directory, with the following code for print() debugging to console.

-- enables printing to console
function love.conf(t)
    t.console = true
end

Connecting to your game server

  1. Edit main.lua to use the sdk. The sdk object can be used to interact with your game server.

-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")
  1. Create a love.load() function, containing sdk.init() and sdk.join(), to connect to the server and join as a player.

--connect to the server
function love.load()
    -- establish a connection to the game server
    sdk.init(123)
    -- join the game server with the player
    sdk.join()
end
  1. Create a love.update(dt) function, with sdk.update() to receive data from the game server.

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
  -- get entity data and positions from the server
  sdk.update()
end
main.lua (basic connection)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

--connect to the server
function love.load()
    -- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
    sdk.init(123,{})
    -- join the game server with the player
    sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
  -- get entity data and positions from the server
  sdk.update()
end
main.lua (basic connection - no comments)
local sdk = require("sdk.sdk")

function love.load()
    sdk.init(123,{})
    sdk.join()
end

function love.update(dt)
  sdk.update()
end

Creating Entities

  1. Create a love.draw() function, to display each entity.

-- display the entities, using their serverside positions
function love.draw()
    -- draw each entity
    for id,entity in pairs(sdk.entities) do
        -- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
		    love.graphics.print("T", entity.X, entity.Y)
		elseif entity.Type == "cat" then
		    love.graphics.print("C", entity.X, entity.Y)
		elseif entity.Type == "player" then
		    love.graphics.print("P", entity.X, entity.Y)
		end
     end
end
main.lua (display entities)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

--connect to the server
function love.load()
    -- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
    sdk.init(123,{})
    -- join the game server with the player
    sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
    -- get entity data and positions from the server
    sdk.update()
end

-- display the entities, using their serverside positions
function love.draw()
    -- draw each entity
    for id,entity in pairs(sdk.entities) do
        -- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
		    love.graphics.print("T", entity.X, entity.Y)
		elseif entity.Type == "cat" then
		    love.graphics.print("C", entity.X, entity.Y)
		elseif entity.Type == "player" then
		    love.graphics.print("P", entity.X, entity.Y)
		end
     end
end
main.lua (display entities - no comments)
local sdk = require("sdk.sdk")

function love.load()
    sdk.init(123,{})
    sdk.join()
end

function love.update(dt)
    sdk.update()
end

function love.draw()
    for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
		    love.graphics.print("T", entity.X, entity.Y)
		elseif entity.Type == "cat" then
		    love.graphics.print("C", entity.X, entity.Y)
		elseif entity.Type == "player" then
		    love.graphics.print("P", entity.X, entity.Y)
		end
     end
end

Test your connection

You now have everything you need to establish a basic connection between LÖVE and the server-side demo code.

  1. Click Actions>Start Game to start the server-side simulation.

You should be able to see all your entities displayed in a messy jumble in the top left of your game window. With the cats, or 'C's, slowly moving. Your Planetary Processing game dashboard map will also show that a player has joined!

Syncing the World Map and Window Origin

The Planetary Processing game world has its origin in the centre of the world, whereas LÖVE 's origin is in the top left of the game window. This can be resolved by displaying entities with an offset.

  1. Create class variables in main.lua for storing an X and Y offset.

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0
  1. Set these variables in the start of love.load().

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
  1. Apply the offset before the entities are drawn each frame, at the start of love.draw().

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)

Your viewport will now be centred on your game world's origin (0,0), where you can see the 'P' icon representing the player.

main.lua (centred origin)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
        -- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
		    love.graphics.print("T", entity.X, entity.Y)
		elseif entity.Type == "cat" then
		    love.graphics.print("C", entity.X, entity.Y)
		elseif entity.Type == "player" then
		    love.graphics.print("P", entity.X, entity.Y)
		end
     end
end
main.lua (centred origin - no comments)
local sdk = require("sdk.sdk")

local screenOffsetX = 0
local screenOffsetY = 0

function love.load()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
end

function love.draw()
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
		    love.graphics.print("T", entity.X, entity.Y)
		elseif entity.Type == "cat" then
		    love.graphics.print("C", entity.X, entity.Y)
		elseif entity.Type == "player" then
		    love.graphics.print("P", entity.X, entity.Y)
		end
     end
end

Syncing the World Map and Window Axis

LÖVE 's top left origin means that the game client's Y axis runs in the opposite direction to the game server's. Inverting any Y position values from the server will correct this.

  1. Create a class variable in main.lua for inverting the Y axis.

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1
  1. Apply that variable to each entity's Y value in love.draw(), to correct its position.

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", entity.X, entity.Y * invertYaxis)
		end
     end
end
main.lua (inverted y axis)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", entity.X, entity.Y * invertYaxis)
		end
     end
end
main.lua (inverted axis - no comments)
local sdk = require("sdk.sdk")

local invertYaxis = -1

local screenOffsetX = 0
local screenOffsetY = 0

function love.load()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
end

function love.draw()
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
			love.graphics.print("T", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", entity.X, entity.Y * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", entity.X, entity.Y * invertYaxis)
		end
     end
end

Syncing the World Map and Window Scale

The entity's coordinates are also currently using pixels, making everything display very close together. You can improve the viewport zoom by scaling the entity positions again.

  1. Create a class variable in main.lua for scaling the viewport zoom.

-- for scaling the viewport zoom
local zoom = 10
  1. Apply that variable to each entity's X and Y values in love.draw(), to correct its position.

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end
main.lua (zoomed)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- for scaling the viewport zoom
local zoom = 10

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end
main.lua (zoomed - no comments)
local sdk = require("sdk.sdk")

local invertYaxis = -1

local screenOffsetX = 0
local screenOffsetY = 0

local zoom = 10

function love.load()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
end

function love.draw()
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end

Player Movement

Now that the game world is visible and orientated, we can start interacting with it. We use sdk.message(msg) to send data to the player entity on the backend.

  1. Edit the love.update(dt) function, to send a table containing XY movement values to the server whenever a WASD input key is pressed.

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
	
	-- a message containing the changes in position 
	local move = {x=0, y=0}
	-- for sending the move message on input
	local sendMove = false
	-- for dictating speed of movement
	local speed = 10
	
	-- on input, update the move message
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	-- if there is an input
	if sendMove == true then
		-- invert the y axis value
		move.y = move.y * invertYaxis
		-- send the move message to the game server
		sdk.message(move) 
	end
end

When this message is sent each frame, the player should now move both visibly in LÖVE and on the game dashboard map.

main.lua (player movement)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- for scaling the viewport zoom
local zoom = 10

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
	
	-- a message containing the changes in position 
	local move = {x=0, y=0}
	-- for sending the move message on input
	local sendMove = false
	-- for dictating speed of movement
	local speed = 10
	
	-- on input, update the move message
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	-- if there is an input
	if sendMove == true then
		-- invert the y axis value
		move.y = move.y * invertYaxis
		-- send the move message to the game server
		sdk.message(move) 
	end
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end
main.lua(player movement - no comments)
local sdk = require("sdk.sdk")

local invertYaxis = -1

local screenOffsetX = 0
local screenOffsetY = 0

local zoom = 10

function love.load()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
	
	local move = {x=0, y=0}
	local sendMove = false
	local speed = 10
	
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	if sendMove == true then
		move.y = move.y * invertYaxis
		sdk.message(move) 
	end
end

function love.draw()
	love.graphics.translate(screenOffsetX, screenOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end

Follow Player Movement

To see the rest of our world, we can use the same world offsetting principle as before to show the world around the player.

  1. Create class variables in main.lua for storing an X and Y offset from the player's position.

-- for offsetting the viewport to centre on the player
local playerOffsetX = 0
local playerOffsetY = 0
  1. Get the player's position, to calculate the offset at the end of the love.update(dt) function.

-- get the offset to centre the viewport on the player
for id,entity in pairs(sdk.entities) do
	if id == sdk.uuid then 
		playerOffsetX = entity.X * zoom
		playerOffsetY = entity.Y * zoom * invertYaxis
		return
	end
end	
  1. Apply the player offset alongside the world position offset, in love.draw().

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window, then centre the viewport on the player
	love.graphics.translate(screenOffsetX - playerOffsetX, 
	                        screenOffsetY - playerOffsetY)
main.lua (follow player)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- for offsetting the viewport to centre on the player
local playerOffsetX = 0
local playerOffsetY = 0

-- for scaling the viewport zoom
local zoom = 10

-- create a custom game window and connect to the server
function love.load()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
	
	-- a message containing the changes in position 
	local move = {x=0, y=0}
	-- for sending the move message on input
	local sendMove = false
	-- for dictating speed of movement
	local speed = 10
	
	-- on input, update the move message
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	-- if there is an input
	if sendMove == true then
		-- invert the y axis value
		move.y = move.y * invertYaxis
		-- send the move message to the game server
		sdk.message(move) 
	end
	
	-- get the offset to centre the viewport on the player
	for id,entity in pairs(sdk.entities) do
		if id == sdk.uuid then 
			playerOffsetX = entity.X * zoom
			playerOffsetY = entity.Y * zoom * invertYaxis
			return
		end
	end	
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window, then centre the viewport on the player
	love.graphics.translate(screenOffsetX - playerOffsetX, 
	                        screenOffsetY - playerOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end
main.lua (follow player - no comments)
local sdk = require("sdk.sdk")

local invertYaxis = -1

local screenOffsetX = 0
local screenOffsetY = 0

local playerOffsetX = 0
local playerOffsetY = 0

local zoom = 10

function love.load()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
	
	local move = {x=0, y=0}
	local sendMove = false
	local speed = 10
	
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	if sendMove == true then
		move.y = move.y * invertYaxis
		sdk.message(move) 
	end
	
	for id,entity in pairs(sdk.entities) do
		if id == sdk.uuid then 
			playerOffsetX = entity.X * zoom
			playerOffsetY = entity.Y * zoom * invertYaxis
			return
		end
	end	
end

function love.draw()
	love.graphics.translate(screenOffsetX - playerOffsetX, 
	                        screenOffsetY - playerOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end

Resizing Your Window (Optional)

At this point you can start customising your LÖVE game client however you like. Take note that actions such as resizing the window will alter your world origin offset and must be corrected.

  1. Set your window to resizable at the start of the love.load() function.

-- create a custom game window and connect to the server
function love.load()
	-- set the window options
	love.window.setMode(0, 0, {resizable=true, vsync=0, minwidth=400, minheight=300})
	-- maximise the window
	love.window.maximize()
  1. Make a love.resize() function, to get the new offset from the resized window.

-- update drawing position offsets, when window is resized
function love.resize()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
end

main.lua (complete - but remember to change the Game ID to your own)
-- use the Planetary Processing SDK
local sdk = require("sdk.sdk")

-- NOTE the Planetary Processing 'y' axis uses screen direction up, Love2d uses screen direction down
-- for inverting 'y' coordinate positions to and from the server
local invertYaxis = -1

-- for offsetting the centre of the world to window centre
local screenOffsetX = 0
local screenOffsetY = 0

-- for offsetting the viewport to centre on the player
local playerOffsetX = 0
local playerOffsetY = 0

-- for scaling the viewport zoom
local zoom = 10

-- create a custom game window and connect to the server
function love.load()
	-- set the window options
	love.window.setMode(0, 0, {resizable=true, vsync=0, minwidth=400, minheight=300})
	-- maximise the window
	love.window.maximize()
	
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	-- establish a connection to the game server (Anonymous Authentication uses an empty table as a parameter)
	sdk.init(123,{})
	-- join the game server with the player
	sdk.join()
end

-- send, receive, and interpret data from the game server each frame
function love.update(dt)
	-- get entity data and positions from the server
	sdk.update()
	
	-- a message containing the changes in position 
	local move = {x=0, y=0}
	-- for sending the move message on input
	local sendMove = false
	-- for dictating speed of movement
	local speed = 10
	
	-- on input, update the move message
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	-- if there is an input
	if sendMove == true then
		-- invert the y axis value
		move.y = move.y * invertYaxis
		-- send the move message to the game server
		sdk.message(move) 
	end
	
	-- get the offset to centre the viewport on the player
	for id,entity in pairs(sdk.entities) do
		if id == sdk.uuid then 
			playerOffsetX = entity.X * zoom
			playerOffsetY = entity.Y * zoom * invertYaxis
			return
		end
	end	
end

-- display the entities, using their serverside positions
function love.draw()
	--apply the offset, to centre the world to the window, then centre the viewport on the player
	love.graphics.translate(screenOffsetX - playerOffsetX, 
	                        screenOffsetY - playerOffsetY)
	
	-- draw each entity
	for id,entity in pairs(sdk.entities) do
		-- display each entity as a letter, using the position from the server
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end

-- update drawing position offsets, when window is resized
function love.resize()
	-- get the window width
	window_width, window_height = love.graphics.getDimensions()
	-- get the world coordinate offset
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
end
main.lua (complete - no comments)
local sdk = require("sdk.sdk")

local invertYaxis = -1

local screenOffsetX = 0
local screenOffsetY = 0

local playerOffsetX = 0
local playerOffsetY = 0

local zoom = 10

function love.load()
	love.window.setMode(0, 0, {resizable=true, vsync=0, minwidth=400, minheight=300})
	love.window.maximize()
	
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
	
	sdk.init(123,{})
	sdk.join()
end

function love.update(dt)
	sdk.update()
	
	local move = {x=0, y=0}
	local sendMove = false
	local speed = 10
	
	if love.keyboard.isDown('w') then                    
		move.y = move.y - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('a') then               
		move.x = move.x - speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('s') then               
		move.y = move.y + speed*dt
		sendMove = true
	end
	if love.keyboard.isDown('d') then               
		move.x = move.x + speed*dt
		sendMove = true
	end
	
	if sendMove == true then
		move.y = move.y * invertYaxis
		sdk.message(move) 
	end
	
	for id,entity in pairs(sdk.entities) do
		if id == sdk.uuid then 
			playerOffsetX = entity.X * zoom
			playerOffsetY = entity.Y * zoom * invertYaxis
			return
		end
	end	
end

function love.draw()
	love.graphics.translate(screenOffsetX - playerOffsetX, 
	                        screenOffsetY - playerOffsetY)
	
	for id,entity in pairs(sdk.entities) do
		if entity.Type == "tree" then
			love.graphics.print("T", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "cat" then
			love.graphics.print("C", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		elseif entity.Type == "player" then
			love.graphics.print("P", 
			                    entity.X * zoom, 
			                    entity.Y * zoom * invertYaxis)
		end
     end
end

function love.resize()
	window_width, window_height = love.graphics.getDimensions()
	screenOffsetX = window_width/2
	screenOffsetY = window_height/2
end

Editing Your Backend Code

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

Push Your Planetary Processing Backend Code 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. 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!

Troubleshooting

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

the Planetary Processing SDK into the same directory by running the following command:

Set the first parameter of sdk.init() to be your Game Id. This is a number which can be found on your , next to your game’s name and repo link.

While connected, the sdk will receive updated data about any entities visible to the player, and store it in sdk.entities. Entities are stored as tables which follow the format in the .

On the Planetary Processing , select your game to enter its dashboard.

your main.lua file using LÖVE.

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

We recommend here to get a sense of what you can do with Planetary Processing. When you add or change entities, make sure your server-side changes match up with your game engine client.

After configuring your game entities and logic, to the game repository:

Go back to your game dashboard in our .

If you want to learn more about updating your server-side code, check out our server-side tutorial video:

If you have encountered any issues, we have a premade demo of this guide: If you have further questions, please get in touch on our .

git
Clone
game dashboard
games web panel
Run
experimenting
push your changes
web panel
https://www.youtube.com/watch?v=QYWtedo1kr4&list=PLW5OY4K85Qhn7lwZeSPVZXH_Lg5IwhjNC
https://drive.google.com/drive/folders/1A7pIeFlghVxURlJEsGoiu0G1UGDuVwc6?usp=drive_link
Discord
repo
documentation
games section of our web panel
LÖVE SDK documentation