Discuss Scratch
- NickyNouse
-
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
-
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
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
-
1000+ posts
NodeJS game
What is a .io type game? .io is a country TLD… 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
- andrewjcole
-
500+ posts
NodeJS game
slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=.io%20games
- Jonathan50
-
1000+ posts
NodeJS game
…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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
-
1000+ posts
NodeJS game
……slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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)
- comp09
-
1000+ posts
NodeJS game
Perhaps you need a small loan of 1 .io is overpriced million hundred dollars?

- Jonathan50
-
1000+ posts
NodeJS game
How does that make them “.io games”? …
Because they all have the TLD “.io” and “.io” is the hipster/techie TLD
- NickyNouse
-
1000+ posts
NodeJS game
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…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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?
- Jonathan50
-
1000+ posts
NodeJS game
I forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?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…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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?
- Dylan5797
-
1000+ posts
NodeJS game
When you say .io everybody thinks Agario or SlitherioI forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?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…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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?

- nanalan
-
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.
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
- liam48D
-
1000+ posts
NodeJS game
Or diepioWhen you say .io everybody thinks Agario or SlitherioI forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?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…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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?

etc etc
They're all kind of similar, like drawings of shapes running around a grid of paper, doing something.
- robinp
-
100+ posts
NodeJS game
.io means “Indian Ocean.”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. I love how
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
- DigiTechs
-
500+ posts
NodeJS game
.io means “Indian Ocean.”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. I love how
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
In which case, just use websocketd and any language of your choice

- comp09
-
1000+ posts
NodeJS game
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..io means “Indian Ocean.”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. I love how
If you're making a Node.js realtime game, though, just use Socket.io. Both agar and slither use it.
In which case, just use websocketd and any language of your choice
- __init__
-
1000+ posts
NodeJS game
I think of cool open source stuff…When you say .io everybody thinks Agario or SlitherioI forgot the reason I wanted to know – why do you say “assuming this is a .io type game”?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…slither.io, agar.io etc…What is a .io type game? .io is a country TLD… 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
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?
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