Jump to content

[WIP] Ninja.io - multiplayer shooter - Box2D


Buizerd
 Share

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.
2 European and 3 North American servers are available.
 
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.
Edit - 15-05-2019: Several versions later: lots of new stuff! Running in Pixi.js v5 now. Party mode has been added, several new maps, new weapons, new sounds, new UI, new account/profile management (WIP), new FX! More to come!
 
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

Link to comment
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)

Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

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!

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

  • 3 months later...

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!

Link to comment
Share on other sites

  • 4 weeks later...
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>

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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. 
 

Link to comment
Share on other sites

  • 11 months later...

So it's been almost exactly a year since my last update. Ninja.io is still under development!

The UI has been significantly overhauled.
New weapons, maps and sounds have been added.
I've also added 'Party mode',  allowing players to create public and private games.

Since adding party mode, the game has seen a significant increase in the number of players.
Unfortunately, the number of concurrent players fluctuates enormously throughout a 24 hour period. From a low of around 20-30 CCU in the early morning to peaks of over 250 players in the evening. (European time)
This made me reluctant to add additional server capacity, as it seems like a waste for at least half of the time. I've opted to increase the capacity today to 5 servers, as lag proved intolerable at 60+ players/server.

Additionally, the Discord has gained thousands of members, but most are inactive, and a 'real' community has yet to form.

Either way, the highscore system is going to be overhauled completely, but right now the focus will be on performance, as it appears that a lot of players have difficulty rendering the game fullscreen.

As always, questions, ideas and suggestions are welcome!

Link to comment
Share on other sites

  • 9 months later...

Alright, another year has passed, and I still consider Ninja.io to be in public alpha.
I've decided to devote more time to this project in 2020.

A lot of additional features have been added, and the player base is steadily growing.

Here's a list of major changes:

  • Settings menus have been added for video, audio and controls.
  • Keyboard bindings/customizations.
  • Major optimizations to the rendering code, especially the world geometry rendering. It also helps that Pixi.JS keeps getting better.
  • The world editor has been improved. While not publicly available yet, it allows for more detailed maps to be created much faster.
  • Several new, more detailed maps.
  • New weapons and improved weapon balance.
  • Numerous server optimizations, resulting in higher player cap and less data transfer.

Major upcoming features include Battle Royale, which is nearing completion, the new ranking system and integration of social features.

World editor screenshot:

editor_screen.thumb.jpg.f5167451b77f1bb21de28006a1582783.jpg

New map, more detail:

New map, more detail:

 

Ideas and feedback are welcome!
 

Link to comment
Share on other sites

  • 10 months later...
On 5/14/2019 at 3:53 PM, Buizerd said:

So it's been almost exactly a year since my last update. Ninja.io is still under development!

The UI has been significantly overhauled.
New weapons, maps and sounds have been added.
I've also added 'Party mode',  allowing players to create public and private games.

Since adding party mode, the game has seen a significant increase in the number of players.
Unfortunately, the number of concurrent players fluctuates enormously throughout a 24 hour period. From a low of around 20-30 CCU in the early morning to peaks of over 250 players in the evening. (European time)
This made me reluctant to add additional server capacity, as it seems like a waste for at least half of the time. I've opted to increase the capacity today to 5 servers, as lag proved intolerable at 60+ players/server.

Additionally, the Discord has gained thousands of members, but most are inactive, and a 'real' community has yet to form.

Either way, the highscore system is going to be overhauled completely, but right now the focus will be on performance, as it appears that a lot of players have difficulty rendering the game fullscreen.

As always, questions, ideas and suggestions are welcome!

i think it  will also look great if u add a knock out match so u can vs both alpha team and bravo team i think. 

Link to comment
Share on other sites

  • 4 months later...
On 1/12/2021 at 12:49 PM, umen said:

@Buizerd

its fun game! 
can you please share information on how you build it ?
what frontend you are using and what backend ? how many servers ? 
Thanks  

Ninja.io uses the Pixi.JS graphics library, the Box2D physics library and the Howler.js audio library.
The Ninja.io game servers run on Node.js. Each ninja.io game can host up to 12 people, and individual games run in separate child processes that are generated and cleaned up by a parent server process.
The number of servers depends on demand.
All server and client code is written in JavaScript. The API was written in PHP.

 

Link to comment
Share on other sites

It has been a while since I replied I see and I think it is great you are still working on it! I just tried it again and tried changing the controls from QWERTY to AZERTY but that did not seem to do anything. I still could not walk around using my QZSD keys. Any idea what went wrong?

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...