Giter VIP home page Giter VIP logo

infinite-tiles's Introduction

Infinite Tiles

tests

Setup

Install dependencies with npm:

npm i
npm run lint

Build resources with mock api strategy:

npm run build

or ws (web socket), production build:

npm run build -- --env API=ws --env WS_HOST=ws://192.168.56.10:8080/game \
    --mode=production

Run

Serve files with a web server with hot loading:

```sh
npm start
# or using web sockets
npm start -- --env API=ws --env WS_HOST=ws://192.168.56.10:8080/game
```

Open your browser at http://localhost:8080.

Protocol

Packet format

The server accepts connections from web socket client and communicates with it using packets. A packet is a sequence of bytes sent over the web socket connection using messagepack serialization format.

network protocol

The meaning of a packet depends on packet type.

Field Name Field Type Notes
t string Packet type. Limited to known packet types.
Depends on the packet type, see details below.

errors

Sent by the server when packet validation fails.

Field Name Field Type Notes
t string errors
errors map of string list The map uses a key to refer to a particular packet field name and a list of strings for multiple error messages.

ping

Sent by the client to the server to sync on clock difference.

Field Name Field Type Notes
t string ping
time float The client unix timestamp in seconds (including milliseconds as the decimal part).

pong

Sent by the server to the client in reply to ping packet.

Field Name Field Type Notes
t string pong
tc float The client unix timestamp as sent in ping packet.
ts float The server unix timestamp in seconds (including milliseconds as the decimal part)..

tiles (viewport change)

Sent by the client when viewport position changes without a need to retrieve corresponding tiles (because corresponding tile meta information available already).

Field Name Field Type Notes
t string tiles
area list of int; [xmin, ymin, dx, dy] Rectangular area related to current viewport position (left, top) and size (width, height). Exactly 4 elements.

tiles (metadata)

Sent by the client when viewport position changes and there is a need to retrieve tile metadata.

Field Name Field Type Notes
t string tiles
area list of int; [xmin, ymin, dx, dy] see above.
ref unsigned byte, [0..127] Reference number to match the server response. Incremented for each new request.
coords list of int; [x,y,...] The list of tiles coordinates relative to area xmin, ymin parameters. The length is even number.

Sent by the server in response to the client request.

Field Name Field Type Notes
t string tiles
ref unsigned byte Reference number, returned back by the server to match the client request.
data list of objects The list of tile metadata corresponding to request coords positions.

place

Sent by the client to create a new object at given tile.

Field Name Field Type Notes
t string place
x int The target tile x-coordinate.
y int The target tile y-coordinate.

Sent by the server to the client to instruct place multiple objects at the given tile coordinates.

Field Name Field Type Notes
t string place
objects list of objects The list of objects to place.

Object contains any meta information, e.g. id.

Field Name Field Type Notes
id string Object id.
x int The target tile x-coordinate.
y int The target tile y-coordinate.

remove

Sent by the server to the client to remove an object by id.

Field Name Field Type Notes
t string removed
objects list of strings The list of objects to remove by id.

move

Sent by the client to the server to move an object to specified tile.

Field Name Field Type Notes
t string move
id string Object id.
x int The target tile x-coordinate.
y int The target tile y-coordinate.

Sent by the server to the client to instruct move multiple objects to the given tile coordinates.

Field Name Field Type Notes
t string move
objects list of objects The list of objects to move.

Object contains the following information.

Field Name Field Type Notes
id string Object id.
x int The target tile x-coordinate.
y int The target tile y-coordinate.
time int The timestamp of the move.
duration int The overall time to perform the move.

moved

Sent by the server to the client to signal an object has been moved to the target tile.

Field Name Field Type Notes
t string move
id string Object id.

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.