🧙‍♂️
Colyseus & OP Arcade
  • Welcome, js13k Builders! 🙌
  • 🖼️Arcadian NFTs
    • What are Arcadians?
    • Arcadians Client SDK
    • Example Code
  • 🏆Arcadia Tournaments
    • Integrate games with Colyseus
    • Getting Started
    • Getting the Url Params
    • Colyseus Walkthrough
    • Multiplayer API
    • Unsecured Game API
    • Unity Walkthrough Introduction
    • Unity Project Integration
    • Godot Guide
    • Additional Resources
    • Work In progress pages
Powered by GitBook
On this page

Was this helpful?

  1. Arcadia Tournaments

Work In progress pages

PreviousAdditional Resources

Last updated 3 years ago

Was this helpful?

on top of that we need to create 2 new files a gameroom.ts file and state.ts files

the state file will handle all the data

the gameroom file will handle all the callbacks

The state will be received by all players so you do not want to have all the info on the state All you want to keep in the state that is allowed to be shared globally

Example battleship game:

  • Shots fired by all players should be in the state

  • Position of the ships should not be in the state otherwise is accessible to all players

Schema is a build in Colyseus and allows to send data back and forward between Client and Server

Schema comes with some parameters {Schema, type, MapSchema, ArraySchema }

Schema -> Colyseus framework

type -> is the language which is typescrypt

MapSchema -> Basically is an object

ArraySchema -> is to use array

We start by creating a RoomState first and we need to know which players are in the room

in the case for single players used in OP Games

you need additional annotation for schema to work

class PlayerState extends Schema {

sessionID: string;

}

export class RoomState extends Schema {

@type({map: PlayerState})

players: MapSchema<PlayerState>

} Lets go to our GameRoom File

import { Client, Room } from "colyseus"

import {RoomState, PlayerState} from "./state"

export class GameRoom extends Room<RoomState> {

}

🏆