Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 372 characters in body
Source Link

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

EDIT: For clarification, my current single setInterval simply does this at about 15hz:

-update each player position based on input

-notify all clients of new positions

input is received as soon as the client sends them, handled by socketio. Sending this many emits is intentional because my server is authoritative and my game is slow (imagine a snakes clone). I intend to allow as many games as there are rooms, which is indefinite (or as many as one server can handle)

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

EDIT: For clarification, my current single setInterval simply does this at about 15hz:

-update each player position based on input

-notify all clients of new positions

input is received as soon as the client sends them, handled by socketio. Sending this many emits is intentional because my server is authoritative and my game is slow (imagine a snakes clone)

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

EDIT: For clarification, my current single setInterval simply does this at about 15hz:

-update each player position based on input

-notify all clients of new positions

input is received as soon as the client sends them, handled by socketio. Sending this many emits is intentional because my server is authoritative and my game is slow (imagine a snakes clone). I intend to allow as many games as there are rooms, which is indefinite (or as many as one server can handle)

added 372 characters in body
Source Link

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

EDIT: For clarification, my current single setInterval simply does this at about 15hz:

-update each player position based on input

-notify all clients of new positions

input is received as soon as the client sends them, handled by socketio. Sending this many emits is intentional because my server is authoritative and my game is slow (imagine a snakes clone)

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?

EDIT: For clarification, my current single setInterval simply does this at about 15hz:

-update each player position based on input

-notify all clients of new positions

input is received as soon as the client sends them, handled by socketio. Sending this many emits is intentional because my server is authoritative and my game is slow (imagine a snakes clone)

Source Link

how to handle server tick update for multiple rooms? (Nodejs)

I'm making a multiplayer game using socketio + nodejs. Currently I use setInterval on my server and requestAnimation on my client render. Now I want to create multiple game instances for each room and so I ask how to do so efficiently:

  1. Do I initialize a new setInterval for every game created and call clearInterval when that game ends? or...
  2. Should I create only one instance of setInterval and loop through each active game and update them?
  3. Should I be using setInterval at all?