lance-gg / lance Goto Github PK
View Code? Open in Web Editor NEWMultiplayer game server based on Node.JS
Home Page: https://lance-gg.github.io/
License: Apache License 2.0
Multiplayer game server based on Node.JS
Home Page: https://lance-gg.github.io/
License: Apache License 2.0
When I launch my game, the first GameObject that gets created has id 0. Attempting to get this object from the GameWorld with gameEngine.world.queryObject({id: 0});
returns null. I'm not sure if the issue here is having an id of 0 to begin with, or if that's by design and the issue is with queryObject. I have overridden some parts of the engines, but I don't think they'd affect this. e.g. not GameWorld or GameObject. Happy to post code but just not sure what to post at this point as I'm not sure whether id:0 is something that's even meant to happen. Thanks!
I'm not sure why, but I needed to change "MyGameEngine" to "NetpongGameEngine" in MyGameEngine.js in order to get the game working.
This issue is not really about incheon, it's about the incheon home page, but I don't want to forget it, so I'm putting it here anyways :)
When I load up the incheon home page, and leave the tab open for a while (as a background tab), then eventually when I select the tab again, the spaaace (demo) game goes nuts.
This is probably a spaaace issue. Though come to think of it, a general solution sounds rather useful.
Right now players are connected indefinitely.
It's important to have feature where the developer defines a timeout in seconds per server, and a player is disconnected if no input was received in the allotted time.
Hi i'm kind of new to the web engine scene altough i'm a programmer and already experimented with phaser and others.
I would like to know if there is any way to create 2D platformer games with the engine: basic gravity, stand on a platform, jumping, etc...
I have looked at the DynamicObject and SimplePhysicsEngine classes and I see nothing related.
I want to create a 4 player 2D arena platformer and this engine has everything needed for it but this.
Feature request to add requestAnimationFrame timestamp to draw function for renderer class
I am making a game called density wars: https://www.youtube.com/watch?v=i7tdJpf6Pnc
using babylonjs.
I've been delaying for a while and want to get the game up and running.
This is a feature request.
Request to add support for UDP - which is a faster networking mechanism than the current TCP, and would probably be built on top of WebRTC.
I don't checked if there is a technical reason to don't do it , but this should be more simple and representative . So we don't need to keep and pass the serializer instances .
Does Lance support React-VR?
Thanks! It looks fascinating - read the article in MSDN magazine :)
It's 1.0.4 on https://www.npmjs.com/package/lance-gg while r1.0.0 on github, and the codes are different.
Which release is recommended?
Thanks.
Please add something like fake latency available here http://www.gabrielgambetta.com/fpm_live.html which would be very useful for testing player movement locally
This is a feature request.
Request for added ability to divide a single game world among multiple Incheon servers,
to ensure that thousands of players can play at the same time in the same game world.
It would be a great improvement in performance and bandwidth usage if the server only sent updates of attributes that have changed, e.g. position or velocity.
Right now it's sending the whole DynamicObject even if it hasn't moved since the last update.
Allowing passing of an object to ClientEngine.connect
which will be used as the second parameter in the io()
call.
documentation: document events collisionStart
and collisionStop
From the slack conversation:
collisionStart
and collisionStop
are emitted only by one physics engine at this time: SimplePhysicsEngine. The registered event handlers will be passed a single argument, an object containing two keys o1
and o2
. The values correspond to the two object IDs that collided.
A major factor in any Game Server is scaling, especially in Node. Running a single Node instance gives limited access to hardware (1 core), as per Node's architecture. This will result in an unscalable game that will only throttle itself.
I noticed that when setting this strategy, any additional properties set in netScheme doesn't get synced. Digging in the code noticed that there are's a call to syncTo
only when the object is created but further updates only update the position. Temporarily work-around extending interpolate
method on the dynamic object as follows, ie:
class myobject extends DynamicObject {
interpolate(nextObj, playPercentage, worldSettings) {
super.interpolate(nextObj, playPercentage, worldSettings);
this.height = nextObj.height;
this.health = nextObj.health;
this.shield = nextObj.shield;
this.kind = nextObj.kind;
this.skills = nextObj.skills;
}
}
For convenience reasons ( eg. initialize visual scene/world ) should be usefull a firstSyncReceived/worldSync or something similar , maybe with pre/post addition .
I can execute once 'client__syncReceived' , but a interesting thing can be add diferent params as syncReceived .
Eg.
beforeWorldSync( theFirstSyncData )
onWorldSync( the objectInstancesCreated ) // this implies divide onAddToWorld ( to onCreateRenderEl onAddToWorld )
afterWorldSync() // the instances are added to the world now
I tried to sync some list and class objects, but it doesn't work, so I dived into source code then I found this:
lance/src/serialize/Serializable.js
Line 139 in 9265585
Hello!
This library is exactly what we've been looking, but it's lacking one thing that is preventing us from using it: An stand-alone client library.
We started using it for a recent game jam but had to abandon it when we realized that it assumes you are using browserfy. Our projects use a build-less environment and are specifically designed not to use browserfy, so we can't use this library unless we completely change our build process.
All we need to be able to use Lance is a client library that we could include with a <script> tag. This is standard for many other javascript libraries, like socket.io:
Like so:
<script src="/socket.io/socket.io.js"></script>
Lance Client Example:
<script src="/js/lance-client.js"><script>
Lance Server Example
const ServerEngine = require('lance-gg').ServerEngine;
If you could provide a client side library that could be included with a script tag, then we could start using Lance and that would AWESOME!
All other tutorial pages have a link at the bottom, but this page simply has
Next: tutorials
It should have:
Next: My First Game: Pong
or in HTML:
Next: <a href="tutorial-MyFirstGame.html">My First Game: Pong</a>
GameEngine on client side begin procesing steps before first server sync, should be nice a option to begin precessing steps when client is syncronized .
Hide the specifics of object ID allocation from the developer.
objectID allocation is sensitive. It involves making sure that
an existing value is not reused. It also involves allocating
from the clientIDspace when creating on the client (extrapolate).
There is no benefit in exposing this to the game developer.
Thanks for this inspiring project!
Currently, it seems to not be possible to use this module with babel (or in an es5 environments), since it exports es6 code (class
es etc). There is no engine
requirements specified in the package.json
file, so I cannot be sure what your intentions are, but the general consensus is to transpile your code to be es5 compatable, unless othervise stated. I think there are two options to solve this:
main
(and module
/ jsnext:main
if you were to add es6 module exports)package.json
engine
section that this module is not es5 compatableWith option 2, babel users can still use your package if they transpile it (babel ignores node_modules by default), but from a user's perspective, option 1 is much more frictionless.
This is a feature request.
Request to preserve game state, at fixed interval rate, or if possible at every step.
The durability test is that if the Incheon game server crashes, another server can be brought online to continue the game from the last saved game state.
Calls like this one are generating strings and polluting memory, even when tracing is disabled:
this.gameEngine.trace.warn(`step drift ${checkType}. [${clientStep} > ${serverStep} + ${maxLead}] Client is ahead of server. Delaying next step.`);
Solution: the trace functions should be passed a callback which builds the string.
Hi guys,
Exist any example with Phaser Framework?
Thanks in advance, Nicholls
This is a feature request.
Request for a visual debugger, which is capable of parsing trace files from server and clients, and re-play the sequence of recorded steps. The visual debugger would show at any given step the game state at the server and each client, preferably on the same map. Additional features include
This is a feature request.
Request to provide a new sample game - which integrates chat services. Since chat services are outside the scope of Incheon, there is a need to demonstrate how someone might integrate an Incheon game with a third-party chat service.
I just need some pointers on where and how I should add a physics engine(Matter.js).
I got interpolation with matter js to work(I simply extended physics engine and updated the engine using step), however I think I might be doing the position, velocity, angle updating wrong.
Here is a GameObject snipet:
class MyGameObject extends DynamicObject {
constructor(id) {
super(id);
this.position.set(0, 0);
this.class = GameObject;
}
onAddToWorld(gameEngine) {
if (gameEngine.physicsEngine) {
//Add body to matter and keep track of it using a reference.
this.matter = ...;
}
}
draw(ctx) {
ctx.fillRect(this.position.x-5, this.position.y-5, 10, 10); //Simple test
}
syncTo(other, options) {
super.syncTo(other);
if (this.matter) //If this has a matter body reference
this.refreshToPhysics();
}
bendToCurrent(original, bending, worldSettings, isLocal, bendingIncrements) {
super.bendToCurrent(original, bending, worldSettings, isLocal, bendingIncrements);
if (this.matter)
this.refreshToPhysics();
}
refreshFromPhysics() { //Note: This is called in the GameEngine::step() (I loop over all objects)
if (this.matter) {
this.position.set(this.matter.position.x, this.matter.position.y);
this.velocity.set(this.matter.velocity.x, this.matter.velocity.y);
this.angle = this.matter.angle;
}
}
refreshToPhysics() {
Matter.Body.setPosition(this.matter, this.position);
this.matter.velocity = this.velocity;
this.matter.angle = this.angle;
}
step () {
super.step();
this.refreshFromPhysics(); //This is not needed since its called from GameEngine.
}
}
This code works but when I have over 200 objects(simple 10x7 rectangles) the game freezes(Im not sure if lance stops sending or if the packet size is too large or etc.). The physics engine when run locally can handle well over that amount.
I then tried using extrapolation:
Does the physics engine need to be deterministic?
I have looked at other PhysicsEngine implementations (Cannon, etc) and see no trace of GameObject.position updatin.
I have not yet tested lance without physics with over 200 objects, but I assume the freezing is my fault and not lance's.
If you need any more info please ask(Im sure if left something out)
Thank you.
Hello,
could i participate in development? I run a modified version of your code here with BabylonJS Renderer and Cannon Physics on server side. Maybe we could share skype contacts?
Regards
Stefan
At http://docs.lance.gg/develop/tutorial-MyFirstGame.html, there is an alternative (almost at the bottom of the page) to simply fetch pong from git. It looks something like this:
NOTE: If you prefer to get a clean working copy, you can run:
git clone https://github.com/lance-gg/lancegame.git pong cd pong git checkout pong yarn install
https://github.com/lance-gg/lancegame.git should probably be https://github.com/lance-gg/netpong
This is a feature request.
Request for an automated cloud deployment, where game developers can provide links to their game repository in github, and game servers are automatically deployed, monitored, load-balanced, and statistics are collected.
lance/src/render/ThreeRenderer.js
Lines 6 to 12 in 78e91bc
I saw your comment there.
I have my own tool that I use for rendering: https://infamous.io
But I suppose that I need to somehow hook it up with Lance in order to take advantage of the client-side prediction of player position, to mitigate network lag, etc. (if I understand correctly, this is what Lance does)
What are requirements for making a renderer? I mean, I see the Renderer
source, but some actual guides would be better. Maybe this discussion can be a starting point for that.
When I run netpong, the server seems to be operating, but when I connect in my browser I only see the two paddles stuck at the top of the screen at their respective locations and the ball stuck at the top left. The server still reports new connections and disconnections and announces that players are scoring. The method that responds to user input does not appear to execute on the server when I press keys in the browser.
When I connect to spaaace, I only see a white screen.
I'm using windows 10. This happens with both chrome and firefox.
I cant seem to build the project with web pack,it says the build parameters do not match webpacks norms.And i scoured the entire documentation,nothing states anything about what particular type of web pack to use
After the recent fix (#39), I noticed that Interpolate strategy now syncs properly all the additional "Simple" netScheme properties, but it doesn't sync the following types:
type: Serializer.TYPES.LIST
type: Serializer.CLASSINSTANCE
As workaround, extending the method interpolate
does the trick.
Hello, testing the game engine in diverse network condition and found out that when the client can't keep up with the server, It starts leaking memory. I found this while playing "spaaace" game with a latency > 350 ms. I started shooting all over the screen and latency + memory started growing until the window hanged.
I think it has to do with the extrapolation and the sync.
Regards,
Guillermo
When serializing an object with the netscheme, do some sanity checks:
is this work for unity?
In the following code snippet, object.playerId
is used to check if an object is owned by the player, but, wouldn't this only return true for the single player object since all other objects use object.ownerId
for ownership?
Lines 103 to 105 in 78e91bc
addObject and removeObject are not used and should be removed from PhysicsEngine
I followed the Pong game and set the object position in processInput in GameEngine like this:
processInput(inputData, playerId) {
super.processInput(inputData, playerId);
console.log(`player ${playerId} pressed ${inputData.input}`);
let player = this.world.getPlayerObject(playerId);
if (player) {
switch(inputData.input) {
case "e":
player.position.z -= 1;
break;
case "d":
player.position.z += 1;
break;
case "s":
player.position.x -= 1;
break;
case "f":
player.position.x += 1;
break;
case "w":
break;
case "q":
break;
default:
break;
}
console.log(inputData, player.position);
}
}
The player's client side log showed different player.position from the server and other clients. The GameEngine seems double processed.
High severity vulnerability which affects all games:
https://nodejs.org/en/blog/vulnerability/july-2017-security-releases/
Hey there, not sure where else to put this, but I am trying to get into your slack chatroom but I don't have an invitation. I'd love to hang out in there with you guys, this is an awesome framework.
On the server, when a player connects, the events server__playerJoined
and playerJoined
are emitted, but on the client, neither are emitted. I was expecting that playerJoined
would be emitted on both.
I do receive a playerJoined
event on the client socket (which makes sense, since ServerEngine sends that separately).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.