This is a demo project showcasing how a Korge client can be used in conjunction with a Ktor websocket server. The multiplayer demo is very simple. When a user is connected to a server, they're assigned a circle that they can move around. The circle can be moved with WASD keys. All other clients connected to the server should be able to see you as you move your circle around.
Note: You can open it up in multiple tabs to create multiple clients.
Server: Contains server code. Built using the Ktor framework.
KorgeClient: Contains client code for connecting to the server. Built using the Korge framework.
GameLogic: The term GameLogic
is a misnomer, this is more like a bunch of shared files that're used between
the Server
and KorgeClient
code.
- Run the server by running
KorgeMultiplayer -> Tasks -> application -> run
in the IntelliJ Gradle panel. - Run the korge client by running
KorgeMultiplayer -> Tasks -> run -> runJvm
.- Note: If you want to connect to the cloud hosted server, set
IS_LOCAL_DEPLOYMENT = false
.
- Note: If you want to connect to the cloud hosted server, set
Note: This is at your own risk because I got it working for myself, but it took a lot of debugging and I didn't record how I got gcloud setup.
- You may need to modify
Server/build.gradle.kts
with your gcloud project names first. - Run
KorgeMultiplayer -> Tasks -> jib -> jibDockerBuild
- If you've setup your gcloud correctly, the image should be available in the
Container Registry
. You can deploy it by using the gcloud GUI. - Update the websocket settings in the Korge client to point to the URL of your server. Follow documentation in the korge client main code for how to setup the connection.