samedi 27 octobre 2018

Socket.io getting a socket every milisecond/frame

My problem started when I wanted to solve a bug of my game. I'm using socket.io, for my multiplayer game. It is a 2D shooter. It's all working fine on the client side. I'm using p5.js, and I'm just sending all the positions of all the bullets, and showing them. When I'm chaning the tab, because I'm moving the bullets in the client, all the bullets that I shot, stop. So, I want to move the bullets in the server. So, I get a socket when I shoot, with the initial position of the bullet, the direction, and the id. I want to move them by the direction, then send them to all the players, every second. But, I need to do it in the newConnection(socket) function, where all the socket.on() are located, so, it is possible to get a socket every frame, without any corelation with the client? Like, every milisecond, or something like that, to get a socket, from the server, like socket.on("something"){} then the function, and I'm getting the socket every milisecond, not from the client. It is possible? Then, how?




Aucun commentaire:

Enregistrer un commentaire