Skip to main content
10 votes

How to optimize collisions

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 ...
Theraot's user avatar
  • 28.2k
5 votes

How to prevent (most) cheating (server-side) in my JavaScript, Node JS, socket.io MORPG?

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 ...
Philipp's user avatar
  • 123k
4 votes
Accepted

Unity websockets client disconnects after server emits with data

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 ...
Nick's user avatar
  • 561
3 votes

How to optimize collisions

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 ...
Philipp's user avatar
  • 123k
3 votes
Accepted

How can I protect against a cheater changing variables on the client?

This won't prevent all cheating but at least will make it harder for the average cheat engine/ change variable hack. Follow the simple advise: Don't trust the client. Now what does that mean? Usually ...
Zibelas's user avatar
  • 4,692
2 votes

Multiplayer Game - Node.js syncing other players' position

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 ...
Vaillancourt's user avatar
  • 16.4k
2 votes
Accepted

How to create additional rooms for new play sessions in a 2-player online game on Node.js?

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 ...
Kal_Torak's user avatar
  • 146
2 votes

Why are not the images loaded in Phaser?

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 ...
Dabe's user avatar
  • 21
2 votes
Accepted

Authoritative game server and database storage

Sending the data to the client before you are sure that it was successfully stored in the database, you run the risk that the client will display information to the user that the server ultimately ...
Hymns For Disco's user avatar
2 votes

Implementing multiplayer aspect of a simple HTML5 game

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 ...
Joza100's user avatar
  • 269
2 votes

Unity websockets client disconnects after server emits with data

I don't have enough reputation to comment yet but I wanted to thank Nick for the above answer. I was facing the same issue but my Unity client was disconnecting when the server sent events that it ...
Dave Seidman's user avatar
2 votes

How to efficiently do one-to-many collision checks?

It sounds like you are looking for collision detection It's a common problem with game engines: how to efficiently check if an object collides with the other(when there are hundreds of objects in the ...
Mangata's user avatar
  • 2,796
1 vote

Multiple small UDP packets vs One big constant UPD packet

What you really need to do here is bit packing and unpacking. Here is a decent tutorial so you can get the most out of each packet, as each bit you send should convey as much information as possible. ...
Jon's user avatar
  • 544
1 vote

websockets authentication security

WSS means Websocket over TLS. So when you force the use of WSS instead of WS, you already solved most problems. Just make sure that The server certificate is valid and signed by a root CA The client ...
Philipp's user avatar
  • 123k
1 vote

How can I implement a Boardgame.io project using Webpack?

This tutorial is derived from the official Boardgame.io Tutorial. It uses Webpack as an alternative to using React or Parcel. Tutorial This tutorial walks through implementing a simple game of Tic-Tac-...
Jim U's user avatar
  • 263
1 vote
Accepted

2D Grid-based Pathfinding with Elevation

Inside your A* algorithm, you have a loop where you iterate over the reachable nodes neighbouring the current node under inspection. If the elevation disparity between the two nodes is greater than ...
DMGregory's user avatar
  • 140k
1 vote

Web Game Security - AntiBot

With web - accept as a fact "Any client is a potential cheater". If you have any game logic on the frontend - nothing will save your game from the cheaters. If you move all the logic to the ...
Vladimir Ishenko's user avatar
1 vote

Can HTTPS webserver host an HTML page that uses JS to connect with secured web socket protocol multiplayer game just like node js?

You can create a client websocket in browser-based JavaScript like this. Note the protocol wss:// before the URL of the server. ...
Philipp's user avatar
  • 123k
1 vote

Trying to understand exactly how the server sends data to the client to prevent malicious actions

In our game the player can move his character by right clicking where they want to go. Does this mean the movement happens on the client side or should the client send a coordinate to the server and ...
Philipp's user avatar
  • 123k
1 vote

Server moving slower than client

I notice you're using setInterval to time your game loop. Javascript's timing functions are imprecise, depends on the browser and prone to drift. It's best if you ...
congusbongus's user avatar
  • 14.9k
1 vote

HTML5 game pases when you go to another tab

Separate your game's code into logic code and drawing code. Put the logic code into a function which you execute at regular intervals with SetInterval. Intervals ...
Philipp's user avatar
  • 123k
1 vote

How to optimize collisions

There are different ways to deal with collision, but we should always prioritize efficiency. A brute force algorithm such as the one you’ve implemented runs n^2 times, or at O(n^2), which is expensive ...
Hashim Jacobs's user avatar
1 vote

Turning a simple HTML5/JS single-player game into a multi-player one

Turning a game developed for singleplayer into a multiplayer game when it was not designed for that from the start can be extremely difficult, both regarding software architecture and regarding game ...
Philipp's user avatar
  • 123k
1 vote

How can I refer to a recipe defined in one function from elsewhere in my code?

When you define a variable with var, it exists only in the local scope: in this case, inside the anonymous function(currentGame). If you want the variable to have ...
DMGregory's user avatar
  • 140k
1 vote
Accepted

Can a block-chain with embedded shared content stop cheating?

Centralized Game If are going to control the servers of the game. You do not need a decentralized solution such as block-chain. In fact, you will not even need cryptography (beyond what is necessary ...
Theraot's user avatar
  • 28.2k
1 vote

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

You should remember that nodejs are single-thread. So if you start few setInterval timers with about 15hz - some of times timers may and will start skipping ticks (as setIntercal can do it when loop ...
Vladimir Ishenko's user avatar
1 vote
Accepted

Implementing Turn based Combat Using Node js

This is just an exercise in modeling the objects you want to represent your game. At the very least, you need a concept of the battling entities (players and creatures) and individual battles. The ...
Jimmy's user avatar
  • 9,059
1 vote

Multiplayer Game - Node.js syncing other players' position

1 - Client send input. 2 - Server calculate and broadcast: destination, direction, velocity and timing function (if you need acceleration or jump curve). 3 - Unit start moving (on server and on ...
Vladimir Ishenko's user avatar
1 vote
Accepted

Implement resolution scaling HTML5 canvas

You have an authoritative server. That server has no screen, so it doesn't make sense to use pixel-measurements in your game mechanics code. So you should make up a coordinate system which works for ...
Philipp's user avatar
  • 123k
1 vote
Accepted

Compare two x and y if they are in a valid range

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: <...
Vaillancourt's user avatar
  • 16.4k

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