Sign in to follow this  
Buizerd

[WIP] Ninja.io - multiplayer shooter - Box2D

Recommended Posts

Ninja.io is a fast paced, 2D multiplayer shooter inspired by games like Soldat, Unreal Tournament and N-game. Currently implemented game modes include Capture the Flag and Deathmatch.
It uses the Box2D physics engine to enable convincing rigid body simulation.
 
Players can make various moves including backflips, rolls, proning, running, flying and crouching.
 
The game is still under active development and I'm willing to devote a great deal of time to finishing this project.
I've made a test server available and you can join it by following these steps:
 - Go to ninja.io
 - Play as Guest
 - Enter a username
 - Join CTF or Deathmatch.
 - Select primary and/or secondary weapon
 
Press H to display table of controls.
 
Decrease the size of the browser window in case it runs slow. I've noticed that some laptops and older systems have trouble maintaining adequate fps.
 
It is currently not possible to register a username, but I've been making progress on an account and highscore system.
 
The game server is currently located in Europe. I plan on running additional servers on other continents and for the site to serve as a gateway to the nearest game server when players join in order to minimize latency.
 
Any thoughts, feedback or suggestions would be much appreciated!
 
Thanks.
 
Edit - 15-12-2017: New version! Sound effects have finally been added, weapons & items have been updated & tweaked, libraries have been updated and many improvements have been made along with numerous bugfixes.
 
I'm currently finishing the implementation of the account system and I'm working on several new maps. More updates will follow soon!
 

splash.jpg

splash2.jpg

splash3.jpg

splash4.jpg

splash5.jpg

splash6.jpg

Share this post


Link to post
Share on other sites

Physic simulation is calculated only by host or by all clients as well?

If by all clients/players, then how you deal with non-deterministic math between different browsers (firefox and chrome still can produce different results using Math.cos/sin etc. and box2d using it as well)

Share this post


Link to post
Share on other sites
On 2-10-2017 at 8:11 PM, totor said:

please add zqsd / updownrightleft or better : personal key settings, for non qwerty-er

I'm planning to add configurable controls and various keyboard presets.

 

On 3-10-2017 at 3:05 PM, hashi said:

Physic simulation is calculated only by host or by all clients as well?

If by all clients/players, then how you deal with non-deterministic math between different browsers (firefox and chrome still can produce different results using Math.cos/sin etc. and box2d using it as well)

Physics are updated by both server and client at 60 hz. Positions, rotations and forces calculated by the server are leading and they are synced with client at 30hz.
Yes, the math is non-deterministic. I also reduce floating point precision to 3 bytes before sending across the network to save bandwidth. This will inevitably desync the client and server a little, but since they are synced at 30hz this is generally barely noticeable.

One remaining problem is the case where a client player will stop running a fraction short of a steep cliff/edge, while the server considers the player to be past the tipping point, so on the server he falls off, while on the client he remains standing. During the following server updates, the player will then feel like he's being 'pulled' off the cliff, since the server is still leading. This can lead to some rubberbanding and jittery movement in some cases. Another situation where minor glitches might occur is when very fast moving objects like bullets strike a small object like a hand grenade. So the client might consider it a hit, causing a ricochet off the grenade, while the server considers it a miss. The nade will then briefly appear to tumble before being corrected by the server updates. Bullets might occasionally end up being 'eaten' by the target without doing damage, even though the client might register a hit.

To say that I greatly underestimated the difficulty of synchronizing a multiplayer physics game like this would be an understatement :lol:
Needless to say there's still plenty of room for improvement here.

Share this post


Link to post
Share on other sites

Looks super cool but you don't accept guests any more :(

To prevent  the issues you mention regarding desynchronization, I completely removed client prediction. The client presses a key (and does nothing), sends it to the server, the server plays the action and notifies everyone. Then everyone does the action. The drawback of this technique is that if you have a bad ping the character will feel slow and unresponsive, but with pings up to 80 it's very playable and players barely notice. This technique is also sweet because you don't need to send updates X times per second, you only send users actions whenever they do one. With a few players (say, under 6) this can lead to 12/15 messages per second at max, which is a nice bandwidth economy. For huge maps with more players, broadcasting 20/30 times per second would probably become the more appropriate technique.

Networking is bitch! Just like you, I completely underestimated this part and building something decent took ages.

Can't wait to test your game!

Share this post


Link to post
Share on other sites
On 2-12-2017 at 10:13 AM, Skeptron said:

Looks super cool but you don't accept guests any more :(

To prevent  the issues you mention regarding desynchronization, I completely removed client prediction. The client presses a key (and does nothing), sends it to the server, the server plays the action and notifies everyone. Then everyone does the action. The drawback of this technique is that if you have a bad ping the character will feel slow and unresponsive, but with pings up to 80 it's very playable and players barely notice. This technique is also sweet because you don't need to send updates X times per second, you only send users actions whenever they do one. With a few players (say, under 6) this can lead to 12/15 messages per second at max, which is a nice bandwidth economy. For huge maps with more players, broadcasting 20/30 times per second would probably become the more appropriate technique.

Networking is bitch! Just like you, I completely underestimated this part and building something decent took ages.

Can't wait to test your game!

Thanks! You can now test the new dev version.

Major changes include the addition of sound effects, weapon & item updates, UI changes, AZERTY keyboard support, weapon tweaks, library updates and numerous bugfixes.

Keep in mind that the server is located in Europe, so players from other continents might have latency issues.

I've been distracted by other things, but finishing this project ASAP has  become a main priority of mine again.

Share this post


Link to post
Share on other sites

Hey, it's been a while since my last update. Here's what's been going on.

The ninja.io website has had a couple of upgrades.
I've added player profiles and a ranking system. Players are now ranked based on their K/D ratio, which is weighted as a function of kill count, maxed out at 1k.
In addition, numerous fixes and updates have been made to both the client and server to improve stability.
Kinematic object animations have been added, allowing moving platforms and rotating structures.
Also, new maps have been added.

The number of players has recently been increasing. Peak moments now approach 100 simultaneous players, and there have been thousands of new subscribers.
I'm still looking for sponsors or advertisers. This has proven to be far more difficult than I expected.

If anyone has suggestions, please let me know. I'm willing to devote a lot of time towards developing this game, but it cannot grow without generating income to allow for increasing server capacity needed to host the game.

Thanks!

Share this post


Link to post
Share on other sites
On 4/15/2018 at 11:21 AM, mehmetegemen said:

I had great fun. How do you think you can expose your game to broader userbase ?

I have no idea. I literally get no response from miniclip or any similar company whenever I email them about a possible partnership.
Advertisers are not interested because the number of players that I have is below a certain threshold(20k/day or something). I regularly have thousands of players a day and 80/90 simultaneous players, but apperently that is not even 1/10 of the amount required?
Due to the nature of running a physics engine the game is probably more costly than most to run. Hence I can only support ~100 clients with current server capacity, which is apparently way below the threshold where potential partners bother to respond.

So the main issue is that I cannot afford to pay for increased server capacity out of my own pocket. I'm stuck with a crappy server. I literally have to drop players during peak hours. The game can't grow to a size where advertiserse might be interested.
As a last resort I've added a Monero miner to help pay for server capacity. This does not even begin to cover the full cost, but at least it helps a little.
I'm reluctant to sell in-game assets since that would turn players into actual customers, which generates expectations that I cannot assure can be met by me working my hobby project over the weekend.

</rant>

Share this post


Link to post
Share on other sites
On 4/22/2018 at 7:08 PM, Marius said:

oh! very nice. But replace the assets! Do you need help?

Maybe. As you can probably tell I'm mostly a software dev and not much of a designer. Feel free to message me about your ideas.

Share this post


Link to post
Share on other sites
On 10/2/2017 at 8:11 PM, totor said:

please add zqsd / updownrightleft or better : personal key settings, for non qwerty-er

This ^. It is really frustrating to have to switch your keyboard layout to qwerty each time you want to play a game. I cannot tell it enough times. Many non-qwerty players often just not play a game because they do not feel like switching layouts.

That being said, it looks nice but it feels like it is really really slow.. The controls are like in slow motion and definitely not accurate. When I press left I expect to go left right away. But now it feels like I am a walking car or something which need time to reach a certain speed.

Share this post


Link to post
Share on other sites
On 5/25/2018 at 11:06 AM, TheBoneJarmer said:

This ^. It is really frustrating to have to switch your keyboard layout to qwerty each time you want to play a game. I cannot tell it enough times. Many non-qwerty players often just not play a game because they do not feel like switching layouts.

That being said, it looks nice but it feels like it is really really slow.. The controls are like in slow motion and definitely not accurate. When I press left I expect to go left right away. But now it feels like I am a walking car or something which need time to reach a certain speed.

Press H to display controls. There you can switch between AZERTY and QWERTY layout.

I've updated the graphics library today. It includes an optimization that improves the rendering speed of the map.
In addiction, I've throttled down the miner which should improve performance on slower systems.

Unfortunately, since the server is located in Western Europe, latency is inevitable for many players outside the region.

Share this post


Link to post
Share on other sites

Well, I am not outside Europe, and in fact, I think you and I share the same country lol. But I will give it another attempt and see if your changes made any improvements. Note: at this moment my download speed is 1.5mbps and my upload speed is the same.

Just out of curiousity, what language did you use to write the front-end and what language did you use to write the backend? Also, which hosting do you use to host your server? And what hosting plans? I am familiar with many and a network-app developer as a prefession so I could help you improve your application on different aspects more than just the gameplay and graphics. 😛

EDIT:

That being said, perhaps I can already. I opened up the console in Chrome and monitored your websocket requests. I noticed that you send websockets each milisecond. This is what is making it slow for me. I may have enough mbps to handle your requests but I do not got the broadband. I know it can be tough to make an online game where every movement needs to be in sync but constantly updating your client is not going to do you good either. My suggestion is to avoid that to begin with and only send websockets when you need it. So instead of a continous update event, you could send a websocket for example when a user presses the key and when he releases it. So on client side it would mean that when the client receives a socket 'keypress' he makes the player move and move and move untill a new event comes called 'keyup' and make the player stop moving. This way you only use 2 websockets while archieving the same result without overloading the network with many sockets at once.

Share this post


Link to post
Share on other sites
4 hours ago, TheBoneJarmer said:

Well, I am not outside Europe, and in fact, I think you and I share the same country lol. But I will give it another attempt and see if your changes made any improvements. Note: at this moment my download speed is 1.5mbps and my upload speed is the same.

Just out of curiousity, what language did you use to write the front-end and what language did you use to write the backend? Also, which hosting do you use to host your server? And what hosting plans? I am familiar with many and a network-app developer as a prefession so I could help you improve your application on different aspects more than just the gameplay and graphics. 😛

EDIT:

That being said, perhaps I can already. I opened up the console in Chrome and monitored your websocket requests. I noticed that you send websockets each milisecond. This is what is making it slow for me. I may have enough mbps to handle your requests but I do not got the broadband. I know it can be tough to make an online game where every movement needs to be in sync but constantly updating your client is not going to do you good either. My suggestion is to avoid that to begin with and only send websockets when you need it. So instead of a continous update event, you could send a websocket for example when a user presses the key and when he releases it. So on client side it would mean that when the client receives a socket 'keypress' he makes the player move and move and move untill a new event comes called 'keyup' and make the player stop moving. This way you only use 2 websockets while archieving the same result without overloading the network with many sockets at once.

Well, client->server updates are limited to ~30/second. Equally, the server updates the clients at ~30hz. Since the actual physics sim updates at 60hz, every step inbetween is dead reckoning. 
I've already made it so that clients only send keyboard and mouse input to the server. The reason you're seeing more traffic is because the direction that players are aiming at will have to be updated based on current mouse position.
For a shooter like this it's critical that the direction the player is facing is updated at a high rate.

In order to reduce network traffic, floating point values in 'update' packets are compressed to 3 bytes, rather than the usual 8 byte precision. This is possible because maps are typically small and large coordinates are not needed.
Information about newly spawned objects(bullets, players, items, etc) is currently sent as JSON because it offered increased flexibility. Sending this as some minimized binary format just like the 'update' information could serve to reduce bandwidth usage and perhaps improve client performance. I just haven't got around to doing this yet.

Both the client and game server(Node.JS) are written in Javascript. The accountserver is written in PHP. 
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.