1.0.4 • Published 11 months ago

gen_game_js v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

GenGame JavaScript

This is JavaScript client library to communicate with GenServer. It can be used for both generic C# project and Unity.

Installation

npm install gen_game_js

Getting Started

First, make sure GenGame server is started. See how to start here.

import { GenGame } from './gen_game'

const genGame = new GenGame('localhost', 4000)

await genGame.connect()
await genGame.authenticateDevice('your-device-id')
const { match_id } = await genGame.createMatch() // <---- save this match id so you can let other player join this game

genGame.onChangeState((payload: object) => {
  console.log('there is update state with payload:', payload)
})

await genGame.setState({ move_x: 110 })

Let the 2nd player join the match:

import { GenGame } from './gen_game'

const genGame = new GenGame('localhost', 4000)

await genGame.connect()
await genGame.authenticateDevice('your-device-id')

await genGame.joinMatch('some-match-id')

await genGame.setState({ chat: 'hi, from player 2' })
1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

1 year ago