Hot answers tagged

8

Do I send a command to move right every frame? Sure. Why not? As long as the player is moving right, of course. If that's spamming the server too much, you could of course just send the command to move right and the command to stop moving right, but you're risking some troubling behavior if you miss the "stop moving" command. You could compromise between ...


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

If you're willing to ease on the requirement that a client should be informed of other clients that are exactly 200 blocks away or closer, then here's an idea: split your map to squares of, say, 200 blocks each side. Then you can keep track of where the client is, and inform the client of all other clients in the adjacent squares. More detailed discussion ...


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

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

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

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 ...


4

Use a fixed time step to start. Fix Your Timestep The server/client need to estimate the RTT (round-trip time) of the connection to correct times. The server is receiving commands from the (very recent) past. Its simulation needs to account for that. It knows where the client was and wanted to move to, not where the client is and wants to move to. The ...


4

To continue from where we left off - the ideal solution is to do all the important work on the server. Since you haven't really said what your game is (Action RPGs can be along a wide spectrum) here are thoughts on how to hide the delays for the user without compromising security in a general way. It is worth it to investigate what working on games in the ...


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

Since it is a single player game, you can do it without any lag at all (assuming you send/receive asynchronous messages). coming to difficulty, its fairly simple implementation. All you do is cross check the action (like price, item available etc.,) which 99.99% will be valid. Now you decide what should happen when some thing fishy happens (like something ...


3

A little example for you, i hope it will be helpful. // Base game object var GObject = function () { // Entities storage this.entity = { hp: new GEntityHp() // ... }; // Storage for buffs, debuffs this.buffs = []; }; GObject.prototype.addBuff = function (buff) { buff.applyTo(this); this.buffs.push(buff); }; // ...


3

Just some short ideas: Only re-calculate the Player's stats when buffs/debuffs occure, not when you need the value. Much likely to what Sequel-based Databases do with indicies (MySQL for example updates the index cache on each write execution providing a verry fast interface for reading data). When you have multiple Types of values, you need to think of a ...


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

You can find one nodejs mysql pack here https://github.com/sidorares/nodejs-mysql-native To scale you can use shards, partitioning, replication (with read only instance), try adding some cache layer like memcached ... (not game specific - there is an article from facebook showing how they scaled mysql) The database choice heavily depends on your data ...


2

General way to handle this is to allow multiple game servers to be spun up, and whenever a new game is started, one is chosen and the client is told to connect to that server. You can then add and remove game servers as necessary to scale horizontally, essentially limited by only by hardware/bandwidth capacities. Scaling up the login servers can be done by ...


2

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


2

With an authoritative server, there is no way of being 100% fair without exposing the player to latency. There is always the possibility that the player made a sudden move that didn't reach the server before the ball passes the paddle, resulting in the player failing even when he should have hit it. But if the ping is low enough and 100% fariness is not ...


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

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 ...


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