GithubHelp home page GithubHelp logo

ddeabreu / metaland Goto Github PK

View Code? Open in Web Editor NEW

This project forked from decentraland-scenes/colyseus-tutorial

0.0 0.0 0.0 8.95 MB

Metaverse

License: Apache License 2.0

Shell 0.32% JavaScript 33.06% TypeScript 64.18% Dockerfile 2.44%

metaland's Introduction

Colyseus Tutorial

A multiplayer scene with [Colyseus]{https://www.colyseus.io/} for websockets multiplayer messaging. The game logic is carried out server-side.

demo

This scene shows you:

  • How to support [Colyseus]{https://www.colyseus.io/} in a Decentraland scene
  • How to set up a simple scene state in Colyseus
  • How to handle game state changes from the server in your scene
  • How to fetch a player's realm
  • How to keep track of the state of each realm as a separate room in your game

The server keeps track of the color selected by each player and the changes in cube colors.

Try it out

Install the CLI

Download and install the Decentraland CLI by running the following command:

$ npm i -g decentraland

Run the server locally

$ cd server
$ npm run build
$ npm run start

NOTE: If this is your first time running the scene then you need to run npm install before npm start

Run the scene

Keep the server running, run the scene on a separate command line window:

$ cd scene
$ dcl start

Scene Usage

Open two separate browser windows, click on the cones to pick a color, then click on the cubes to paint them that same color.

Using Colyseus SDK with Decentraland

Install colyseus.js:

npm install --save colyseus.js

Add colyseus.js to your "bundleDependencies" in your package.json:

  "bundleDependencies": [
    "colyseus.js"
  ]

To avoid TypeScript compilation errors you'll need to edit tsconfig.json, and include a few ///<reference to your source-code, as you can see in the scene/src/connection.ts file.

{
  "compilerOptions": {
    // ...
    "noLib": false,
    // ...
  }
}
///<reference lib="es2015.symbol" />
///<reference lib="es2015.symbol.wellknown" />
///<reference lib="es2015.collection" />
///<reference lib="es2015.iterable" />

import { Client } from "colyseus.js";

The Colyseus SDK requires a few TypeScript libraries that are excluded by default by Decentraland.


Creating a Colyseus server:

npm init colyseus-app ./server

Deploying to Colyseus Arena

npm run build

Upload the lib folder from the Arena control panel.

More

Learn more about how to build your own scenes in our documentation site.

If something doesn’t work, please file an issue.

Copyright info

This scene is protected with a standard Apache 2 licence. See the terms and conditions in the LICENSE file.

metaland's People

Contributors

nearnshaw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.