All Projects → doorbash → colyseus-kotlin

doorbash / colyseus-kotlin

Licence: MIT license
⚔ Implementation of Colyseus client using Kotlin

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to colyseus-kotlin

Colyseus
⚔ Multiplayer Framework for Node.js
Stars: ✭ 3,817 (+14580.77%)
Mutual labels:  multiplayer, game-server, colyseus
Crystalshire
Legacy VB6 open-source ORPG
Stars: ✭ 24 (-7.69%)
Mutual labels:  multiplayer, game-server, multiplayer-game
basic multiplayer unity
UDP Client-Server implementation in Unity
Stars: ✭ 44 (+69.23%)
Mutual labels:  multiplayer, game-server, game-networking
Frag.exe
Multiplayer First-Person Shooter written in C++ using my own engine, Qor
Stars: ✭ 8 (-69.23%)
Mutual labels:  multiplayer, multiplayer-game
Gameproject3
游戏服务器框架,网络层分别用SocketAPI、Boost Asio、Libuv三种方式实现, 框架内使用共享内存,无锁队列,对象池,内存池来提高服务器性能。还包含一个不断完善的Unity 3D客户端,客户端含大量完整资源,坐骑,宠物,伙伴,装备, 这些均己实现上阵和穿戴, 并可进入副本战斗,多人玩法也己实现, 持续开发中。
Stars: ✭ 655 (+2419.23%)
Mutual labels:  multiplayer, game-server
Openspades
Compatible client of Ace of Spades 0.75
Stars: ✭ 769 (+2857.69%)
Mutual labels:  multiplayer, multiplayer-game
Forgenetworkingremastered
In short, Forge Networking is a free and open source multiplayer game (multi-user) networking system that has a very good integration with the Unity game engine. You wanna make a multiplayer game or real time multi-user application? This is the library for you.
Stars: ✭ 1,338 (+5046.15%)
Mutual labels:  multiplayer, multiplayer-game
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (+134.62%)
Mutual labels:  multiplayer, game-server
Reldens
Reldens - You can make it - Open Source MMORPG Platform
Stars: ✭ 130 (+400%)
Mutual labels:  multiplayer, multiplayer-game
Mrboom Libretro
Mr.Boom is an 8 player Bomberman clone for RetroArch/Libretro
Stars: ✭ 162 (+523.08%)
Mutual labels:  multiplayer, multiplayer-game
Magicallife
A 2d game that aspires to be similar to Rimworld, with more depth, magic, and RPG concepts.
Stars: ✭ 145 (+457.69%)
Mutual labels:  multiplayer, multiplayer-game
Team-Capture
Team-Capture - A multiplayer FPS game, inspired by games like Quake and TF2. Done in Unity
Stars: ✭ 81 (+211.54%)
Mutual labels:  multiplayer, multiplayer-game
Nakama
Distributed server for social and realtime games and apps.
Stars: ✭ 5,293 (+20257.69%)
Mutual labels:  multiplayer, game-server
Agones
Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
Stars: ✭ 4,252 (+16253.85%)
Mutual labels:  multiplayer, game-server
Ancientbeast
Turn Based Strategy Game. Master your beasts! 🐺
Stars: ✭ 907 (+3388.46%)
Mutual labels:  multiplayer, multiplayer-game
Game Networking Resources
A Curated List of Game Network Programming Resources
Stars: ✭ 4,208 (+16084.62%)
Mutual labels:  multiplayer, game-networking
Lance
Multiplayer game server based on Node.JS
Stars: ✭ 1,161 (+4365.38%)
Mutual labels:  multiplayer, game-server
Segs
💪 SEGS - Super Entity Game Server
Stars: ✭ 190 (+630.77%)
Mutual labels:  multiplayer, game-server
colyseus-cocos2d-x
⚔️ Colyseus Multiplayer SDK for Cocos2d-x
Stars: ✭ 14 (-46.15%)
Mutual labels:  multiplayer, colyseus
MyRTS
Multiplayer RTS game prototype written in Java using LibGDX
Stars: ✭ 17 (-34.62%)
Mutual labels:  multiplayer, multiplayer-game

Colyseus-Kotlin

Implementation of Colyseus client using Kotlin

Download

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.doorbash:colyseus-kotlin:0.14.5'
}

How to

Define schema class

class MyState : Schema() {
    @SchemaField("0/ref", PrimitivesTest::class)
    var primitives = PrimitivesTest()

    @SchemaField("1/array/ref", Player::class)
    var players = ArraySchema(Player::class.java)

    @SchemaField("2/map/ref", Cell::class)
    var cells = MapSchema(Cell::class.java)
}

class Cell : Schema() {
    @SchemaField("0/float32")
    var x = Float.default

    @SchemaField("1/float32")
    var y = Float.default
}

class PrimitivesTest : Schema() {
    @SchemaField("0/uint8")
    var _uint8 = Short.default

    @SchemaField("1/uint16")
    var _uint16 = Int.default

    @SchemaField("2/uint32")
    var _uint32 = Long.default

    @SchemaField("3/uint64")
    var _uint64 = Long.default

    @SchemaField("4/int8")
    var _int8 = Byte.default

    @SchemaField("5/int16")
    var _int16 = Short.default

    @SchemaField("6/int32")
    var _int32 = Int.default

    @SchemaField("7/int64")
    var _int64 = Long.default

    @SchemaField("8/float32")
    var _float32_n = Float.default

    @SchemaField("9/float32")
    var _float32_p = Float.default

    @SchemaField("10/float64")
    var _float64_n = Double.default

    @SchemaField("11/float64")
    var _float64_p = Double.default

    @SchemaField("12/boolean")
    var _boolean = Boolean.default

    @SchemaField("13/string")
    var _string = String.default
}

class Player : Schema() {
    @SchemaField("0/int32")
    var x = Int.default
}

Join or create a room:

val client = Client("ws://localhost:2567")
with(client.joinOrCreate(MyState::class.java, "game")) {
    println("connected to $name")

    // setup listeners
}

Setup listeners

/* Room listeners */
onLeave = { code -> println("onLeave $code") }

onError = { code, message ->
    println("onError $code $message")
}

onStateChange = { state, isFirstState ->
    println("OnStateChange")
    println(isFirstState)
}

/* Schema listeners */
state.primitives.onChange = { changes ->
    for (change in changes) {
        with(change!!) {
            println("$field: $previousValue -> $value")
        }
    }
}

state.players.onAdd = { player, key ->
    println("player added: " + key + "  " + player.x)
}

state.players.onRemove = { player, key ->
    println("player removed: " + key + "  " + player.x)
}

/* Message Listeners */
//Set listener by message type
onMessage("hi") { cells: MapSchema<Cell> ->
    println("cells size is ${cells.size}")
    println(cells)
}

// Set listener by type
onMessage { primitives: PrimitivesTest ->
    println("some primitives...")
    println(primitives._string)
}

// Set listener by type id
onMessage(2) { cell: Cell ->
    println("handler for type 2")
    println(cell.x)
}

Send message to server:

// Send message with message type
send("fire", Math.random() * 100)

// Send a schema with type id
send(2, Cell().apply { x = 100f; y = 200f })

// Send only the message type or type id
send("hello")
send(3)

Usage examples

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].