Discuss Scratch

herohamp
Scratcher
1000+ posts

NodeJS game

So I started working on a nodeJS game but ran into an issue! How can I make it so unlimited players can join and give the players smooth moments?? Source
herohamp
Scratcher
1000+ posts

NodeJS game

*Reserved*
NickyNouse
Scratcher
1000+ posts

NodeJS game

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
robinp
Scratcher
100+ posts

NodeJS game

On connection, store the socket inside an array so you can access it later. Then another json object contain player info with their socked id as a key (This is an example. Many people have different methods). Then send relevant player info to all clients (x,y and rotation). The data for each player will be initialized/added during the connection event.

To change player data just use socket.id to get the player “id” and change the player info inside the object. The data the client send should not be positional data. The client should be sending the current mouse position and key presses. Why? Because if I were to modify your code it send a custom x or y position, then I could simply teleport myself.

To get smooth movement send player updates to the client very fast. The rate should be at around 20-30 times a second (This should be done for fast connections)
For slower connections 200+ms ping, use a slower server-client sync rate but animate player movements. To make it even smoother, you can send a collection of player movements done between each sync to make the movements more accurate and realistic.

Also, many people recommend not to use socket.io due to a http polling fallback. This however can be disabled server side. See http://stackoverflow.com/questions/11451214/disabling-jsonpolling-for-socket-io

Last edited by robinp (May 27, 2016 14:44:55)

Jonathan50
Scratcher
1000+ posts

NodeJS game

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
andrewjcole
Scratcher
500+ posts

NodeJS game

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games
Jonathan50
Scratcher
1000+ posts

NodeJS game

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
Firedrake969
Scratcher
1000+ posts

NodeJS game

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?

Because they all have the TLD “.io” and “.io” is the hipster/techie TLD

Last edited by Firedrake969 (May 27, 2016 22:38:20)

Dylan5797
Scratcher
1000+ posts

NodeJS game

.io is overpriced
comp09
Scratcher
1000+ posts

NodeJS game

Dylan5797 wrote:

.io is overpriced
Perhaps you need a small loan of 1 million hundred dollars?
Jonathan50
Scratcher
1000+ posts

NodeJS game

Firedrake969 wrote:


Because they all have the TLD “.io” and “.io” is the hipster/techie TLD
How does that make them “.io games”?
NickyNouse
Scratcher
1000+ posts

NodeJS game

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
I call them that because all of these games have that TLD. And I think they picked it because I/O as in input-output
Jonathan50
Scratcher
1000+ posts

NodeJS game

NickyNouse wrote:

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
I call them that because all of these games have that TLD. And I think they picked it because I/O as in input-output
I forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?
Dylan5797
Scratcher
1000+ posts

NodeJS game

Jonathan50 wrote:

NickyNouse wrote:

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
I call them that because all of these games have that TLD. And I think they picked it because I/O as in input-output
I forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?
When you say .io everybody thinks Agario or Slitherio
nanalan
Scratcher
100+ posts

NodeJS game

I love how .io means “Indian Ocean.”
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
liam48D
Scratcher
1000+ posts

NodeJS game

Dylan5797 wrote:

Jonathan50 wrote:

NickyNouse wrote:

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
I call them that because all of these games have that TLD. And I think they picked it because I/O as in input-output
I forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?
When you say .io everybody thinks Agario or Slitherio
Or diepio

etc etc

They're all kind of similar, like drawings of shapes running around a grid of paper, doing something.
robinp
Scratcher
100+ posts

NodeJS game

nanalan wrote:

I love how .io means “Indian Ocean.”
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
Agar most defiantly does not use socket.io. Agar uses a c++ based backend and sends binary data to the client to update positions and such. Socket.io is a nodejs library for realtime communication using websockets and http polling.
DigiTechs
Scratcher
500+ posts

NodeJS game

robinp wrote:

nanalan wrote:

I love how .io means “Indian Ocean.”
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
Agar most defiantly does not use socket.io. Agar uses a c++ based backend and sends binary data to the client to update positions and such. Socket.io is a nodejs library for realtime communication using websockets and http polling.

In which case, just use websocketd and any language of your choice
comp09
Scratcher
1000+ posts

NodeJS game

DigiTechs wrote:

robinp wrote:

nanalan wrote:

I love how .io means “Indian Ocean.”
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
Agar most defiantly does not use socket.io. Agar uses a c++ based backend and sends binary data to the client to update positions and such. Socket.io is a nodejs library for realtime communication using websockets and http polling.

In which case, just use websocketd and any language of your choice
If you aren't going to run at agar.io scale, try using uws. It seems to be the lightest and fastest option for websockets.
__init__
Scratcher
1000+ posts

NodeJS game

Dylan5797 wrote:

Jonathan50 wrote:

NickyNouse wrote:

Jonathan50 wrote:

andrewjcole wrote:

Jonathan50 wrote:

NickyNouse wrote:

You could group the users into different servers. Also (assuming this is a .io type game) only send each user data for other users they can see/interact with
What is a .io type game? .io is a country TLD…
slither.io, agar.io etc…
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games

Why do you call them “.io games”, and why do they all have .io domains in the first place?
I call them that because all of these games have that TLD. And I think they picked it because I/O as in input-output
I forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?
When you say .io everybody thinks Agario or Slitherio
I think of cool open source stuff…

Honestly, I used to distinguish responsive web apps by having the .io domain or not. Now that whole thing has been taken over by stupid web games…

Oh well, at least I have .cc to fall back on

Powered by DjangoBB