Skip to main content

Quick Start

Build a multiplayer game for the Rune platform and its millions of players. Rune handles netcode, servers, voice chat, matchmaking, spectating, and much more.

Install

Create a new Rune game project by running:

npx rune-games-cli@latest create

or follow this guide to port your existing game to Rune!

Game Logic

Create a file named logic.js with a setup function that returns initial values for your game state that should be synced across players. Add an action that modifies this game state and call Rune.initLogic() to initialize. For instance, to give all players a score and have an action that just increments the score:

// logic.js

Rune.initLogic({
minPlayers: 1,
maxPlayers: 4,
setup: (allPlayerIds) => {
const game = { scores: {} }
for (let playerId of allPlayerIds) {
game.scores[playerId] = 0
}
return game
},
actions: {
incrementScore(playerWhoGotPoints, { game }) {
game.scores[playerWhoGotPoints]++
},
},
})

Rendering

Next, integrate your game UI to react to game state changes and send actions to the logic layer. This code may live anywhere except in logic.js; the docs will refer to client.js:

// client.js

// Your game setup code...

// Trigger an action based on user input
button.onClick = () => {
Rune.actions.incrementScore({
playerWhoGotPoints: "player1",
})
}

// Callback you define for when something changes (e.g. someone made an action)
function onChange({ game, yourPlayerId, players, action, event }) {
// Your game visuals update code...
}

// Initialize the Rune SDK once your game is fully ready
Rune.initClient({ onChange })

Next Steps