Hot answers tagged

8

Query only nearby objects As you already know, you need to check only nearby objects. This means that you need a way to retrieve a list of nearby objects to check. To do that, you need to divide the map in areas, and each area has a list of objects that are currently there. Then, you can solve collisions within each area※. ※: Areas do not overlap. Yet, ...


7

Yes. You definitely should. Use Let's Encrypt to get a free SSL certificate (or as many as you want or need). SSL is always good to have: without it, man-in-the-middle attacks will be launched, by the NSA if no-one else. Most multiplayer games (e.g. Minecraft) just use raw packets. There's little reason to encrypt packets after one is authenticated as only ...


7

Hello visitors of Jindsay's Card Game Forum. Here is your friend xXx_GameH4x0rPhilipp_xXx with another cheat for you. Do you want to win every game? Here is a simple hack which works with every web browser: Press F12 Click on "Debugger" Select check_win.js There is now a window with lots of programming code. Don't worry, you don't need to understand any of ...


5

When you use two different physics engines, it will be almost impossible that they will always come to the exact same results. Large physics systems can behave quite chaotically (small changes in variables create drastically different outcomes). So considerable desynchronization will become inevitable. The most obvious solution would be to keep the physics ...


5

Socket.io will emit connected event for every connected socket. So in your case you will create loads of loops there. It is better to have list of sockets, and one loop separately. As you've said - your case is simple - so keep it simple, do not overcomplicate. var sockets = { }; server.on('connected', function(socket) { // runs for every connection ...


5

I believe setTimeout is good enough for your needs. I am, myself, facing a similar situation and I am going with setTimeout. This awesome article on BNG helped me better understand what a I have to do (or, at least, try): Real Time Multiplayer in HTML5. About the link: It talks mostly about the multiple game loops and networking them. It's pretty cool. ...


5

Doing basically anything on client-side apat from the inputs is a bad idea. And believe me, if the programmers could collect inputs on the server side, so the client couldn't fake them, then they would happily do so. Literally anyone can change the code to always register a winning condition. If they make it send it back to the server, than it's even worse. ...


5

There is just one way to prevent cheating: Handle all your game mechanics on the server. Anthing else is snake-oil. That applies even more to web-based games where every player can access all kinds of powerful cheating tools just by pressing F12. Anti Cheat Tools (ACTs) work by infiltrating the players operating system and doing all kinds of low-level ...


4

The short of it is that your game design and art both need to be built around the realities of networked play. When the user clicks, they should not immediately attack. Instead, the animation/effects should be a "pre-attack" visual that can be smoothly transitioned into a full attack animation/effect or a canceled effect. More over, this pre-attack should ...


4

Do lazy evaluation of player build progression. Whenever you need to retrieve the state of a player from your database for any reason, check how old that state is, progress the time which elapsed since the last save, and then put it back into the database. For example: The current timestamp is 2017-06-15 15:49:23. You want to know how many windmills player ...


4

Finally, after many hours of debugging, found an error. This library expects data from server to be a JSON object, and not string (that's a bit weird because this library allows to send both string and object to the server) so instead of io.to(key).emit("update", JSON.stringify(data)); I did: io.to(key).emit("update", { data: "isMine" }); ...


3

Yes, it's quite possible. In essence, this would just be extensive scripting, and scripting is very common in game development. You can do whatever you can in JS, and use C/C++ for the stuff you can't get to behave with JS. I wouldn't bother with Node.js and go straight for V8, which is not that hard to integrate. V8 has recently added isolates, which make ...


3

My game is working fine for now, but there's no real way to test with 50 players until people actually start playing. There is. Just write a bot client for stress-testing your gameserver. While it is hard to write a convincing bot which behaves exactly like a real player would behave, it is usually not that difficult to write one which just logs in, joins a ...


2

It's better to use setImmediate() or process.nextTick() for game loop. setImmediate vs. nextTick


2

Node has build in timer functionality well documented on their website. Set the delay to 20 * 1000 and have the code in the callback trigger the fold then inform the client. Timers setTimeout(callback, delay, [arg], [...])# To schedule execution of a one-time callback after delay milliseconds. Returns a timeoutObject for possible use with ...


2

In my opinion using node for a game client is not the best option. Node.js is usually used for the server side of a game and not the client. If you like CoffeScript why don't you create an HTML 5 game with one of the tons of free JavaScript game engines out there? This would also spare you the hassle of creating OpenGL bindings (you'd have to use WebGL ...


2

For server-side stuff you have a couple of options. The first is to entirely extrapolate all your collisions working off of the assumption that you will have frequent-enough messages from clients, communicating all meaningful state change through the server, which then will run validation on game events only as it receives IO callbacks from the client ...


2

Your game timing system should have its own internal clock that is started when the game begins (this can be setup by the server to force clients to be the same). Have you considered using this internal timer? It would be valid, and the same across all clients.


2

Interesting Question! Let me try to answer some of your points: 1 - How do I simulate physics on the server, do I need to rewrite parts of client side on the server side using a JavaScript physics engine? Yes, essentially, thats what you would do, if you want physics on the server. You have to ask you the question: Do I need the server to validate ...


2

In desktop games this is usually resolved by having the client assume it's allowed to do something (and running it's own physics engine etc). You could do the same thing here. The client uses the server to sync for online save or multiplayer and the server can reject events sent from the client; if this is the case the clients environment is set to what the ...


2

With the following model the client will render only what the server tells him to render. The client becomes an input & input-pre-emission-validator The server is the final-validator (don't trust clients) Then the client renders what the server told him [1] Client action request creation upon user input : Client clicks on an enemy, triggering your ...


2

Figured out the problem: it was a remnant from a previous build in which I was trying to store all enemy data in variables and was not closing the registration of enemies properly: changed socket.on('enemyRegister', function(data){ // builds a monster on the client socket.broadcast.emit('enemyRegister', data); to socket.on('...


2

You need the "absolute" method: abs(). This will return a value that is always greater than or equal to zero. This way, you only have to check once for each axis: var range = 10; if ( abs(oldVector[0] - newVector2[0]) < range && abs(oldVector[1] - newVector2[1]) < range ) { // valid } else { // not valid } This will allow you to check if ...


2

Approach 1) is traditionally used in RTS types of games where timing is very important. However, this approach has the downside of increasing by a lot the chances of clients cheating. Since the client simulates the physics and everything else, it has to know the whole state to keep it in sync with other clients. In order to do that, it has to know of the ...


2

I would suggest not using Socket.IO's rooms mechanism. It is not very flexible and isn't very appropriate for a robust server architecture. Here's a quick scribble of how you could structure your rooms on the server. Obviously you'll want to use your own class for Player instead of the socket object, lookup rooms by id etc, but I wanted to keep the example ...


2

I remember struggling with the same thing actually and here it is. I figured it out not long time ago. I will use the rotating triangle as an example. The server is the one that needs to figure out that the triangle needs to start rotating. The triangle should have two things: Rotation Rotation velocity Now, let's say that the every client has it's own ...


2

I tested your Phaser Javascript code and it works fine. So I'm thinking it's a problem with how you've set up your server. Look up Express.js, its an NPM module that makes it really easy to set up Nodejs servers. If you want to continue using the more bare-bones http, then make sure you're using fs and that callback function properly, I don't know enough ...


Only top voted, non community-wiki answers of a minimum length are eligible