All Projects → jondubois → Iogrid

jondubois / Iogrid

Licence: mit
Multiplayer game engine/framework built using SocketCluster and Phaser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Iogrid

Pydark
PyDark is a 2D and Online Multiplayer video game framework written on-top of Python and PyGame.
Stars: ✭ 201 (-55.82%)
Mutual labels:  framework, game-development, game-engine, multiplayer
Openage
Free (as in freedom) open source clone of the Age of Empires II engine 🚀
Stars: ✭ 10,712 (+2254.29%)
Mutual labels:  game-development, game-engine, multiplayer
Evennia
Python MUD/MUX/MUSH/MU* development system
Stars: ✭ 1,309 (+187.69%)
Mutual labels:  game-development, game-engine, multiplayer
Rhubarb
A WebSocket library optimized for multiplayer JS games, works on WebWorkers with binary data.
Stars: ✭ 167 (-63.3%)
Mutual labels:  game-development, multiplayer, websocket
Reldens
Reldens - You can make it - Open Source MMORPG Platform
Stars: ✭ 130 (-71.43%)
Mutual labels:  game-development, multiplayer, phaser
Dodgem
A Simple Multiplayer Game, built with Mage Game Engine.
Stars: ✭ 12 (-97.36%)
Mutual labels:  game-development, game-engine, multiplayer
Kaetram Open
An open-source 2D HTML5 adventure based off BrowserQuest (BQ).
Stars: ✭ 138 (-69.67%)
Mutual labels:  game-development, game-engine, multiplayer
Gameproject3
游戏服务器框架,网络层分别用SocketAPI、Boost Asio、Libuv三种方式实现, 框架内使用共享内存,无锁队列,对象池,内存池来提高服务器性能。还包含一个不断完善的Unity 3D客户端,客户端含大量完整资源,坐骑,宠物,伙伴,装备, 这些均己实现上阵和穿戴, 并可进入副本战斗,多人玩法也己实现, 持续开发中。
Stars: ✭ 655 (+43.96%)
Mutual labels:  game-development, game-engine, multiplayer
Phaser Node Kit
Rapid Game Development with PhaserJS and Node for Modern Browsers
Stars: ✭ 39 (-91.43%)
Mutual labels:  framework, game-development, phaser
Duality
a 2D Game Development Framework
Stars: ✭ 1,231 (+170.55%)
Mutual labels:  framework, game-development, game-engine
O2
2D Game Engine with visual WYSIWYG editor
Stars: ✭ 121 (-73.41%)
Mutual labels:  framework, game-development, game-engine
Donerserializer
A C++14 JSON Serialization Library
Stars: ✭ 31 (-93.19%)
Mutual labels:  framework, game-development, game-engine
Fxgl
Stars: ✭ 2,378 (+422.64%)
Mutual labels:  framework, game-development, game-engine
Awesome Haxe Gamedev
Resources for game development on haxe
Stars: ✭ 213 (-53.19%)
Mutual labels:  framework, game-development, game-engine
Ncine
A cross-platform 2D game engine
Stars: ✭ 372 (-18.24%)
Mutual labels:  game-development, game-engine
Rtm
Realtime Math
Stars: ✭ 373 (-18.02%)
Mutual labels:  game-development, game-engine
Unity2d Components
A constantly evolving array of Unity C# components for 2D games, including classes for pixel art cameras, events & messaging, saving & loading game data, collision handlers, object pools, and more.
Stars: ✭ 375 (-17.58%)
Mutual labels:  game-development, game-engine
Game
⚔️ An online JavaScript 2D Medieval RPG.
Stars: ✭ 388 (-14.73%)
Mutual labels:  game-development, game-engine
Ark
ARK is a lightweight, agility, elastic, distributed plugin framework written in C++,make it easier and faster to create your own application service.
Stars: ✭ 370 (-18.68%)
Mutual labels:  framework, game-development
Agones
Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
Stars: ✭ 4,252 (+834.51%)
Mutual labels:  game-development, multiplayer

IOGrid

Join the chat at https://gitter.im/SocketCluster/iogrid

IOGrid is an IO game engine/framework built using SocketCluster and Phaser. It lets you build multi-player games like Agar.io and Slither.io and also multi-player simulations/experiments for research purposes. It is designed to scale across multiple processes to make use of all CPU cores on a machine.

The game world is divided into cells which will be distributed across available SC worker processes. Basic initial tests indicate that this engine can scale linearly across available CPU cores - I've found that doubling the number of worker processes allowed the engine to handle approximately double the number of bots whilst maintaining the average CPU usage per worker process at 50%.

Each cell in the world has its own instance of a cell controller (cell.js) - Ideally, this is where you should put all your back end game logic. If you follow some simple structural guidelines, your code should automatically scale. With this approach, you should be able to build very large worlds which can host thousands of concurrent players.

If you've built a game using this engine, feel free to contribute back to this repo. Also, feel free to get in touch with me directly by email (see my GitHub profile http://github.com/jondubois) if you'd like to chat, have feedback, need advice or need help with a project.

IOGrid demo

Special thanks to the Percepts and Concepts Laboratory at Indiana University (http://cognitrn.psych.indiana.edu/) for sponsoring this project.

Developing

The front-end code is in public/index.html, the back-end code is in worker.js and cell.js. Read the comments in the code for more details about how it all works.

Running

To run on your machine, you need to have Node.js v6.0.0 or higher installed. Then you can either clone this repo with Git using the command:

git clone [email protected]:SocketCluster/iogrid.git

... Or you can download the zip: https://github.com/SocketCluster/iogrid/archive/master.zip and extract it to a directory of your choice.

Once you have this repo setup in a iogrid directory on your machine, you need to navigate to it using the terminal and then run:

npm install

Then (while still inside the iogrid directory) you can launch the SocketCluster server using:

node server

To run the demo, navigate to http://localhost:8000 in a browser - You should see a rabbit which you can move around using the arrow keys.

To test the multi-player functionality from your localhost:

Open up another browser window/tab to http://localhost:8000 and put it side-by-side with the first window/tab - You should now have two rabbits - Each one can be controlled from a different tab.

Note that while this demo demonstrates a few important optimizations, it can still be optimized further. For production usage, among other things, you may want to improve the current codec to make the packets that are sent to the client even smaller. You may want to build your own codec on top of https://github.com/SocketCluster/sc-codec-min-bin.

If you want to run the server on port 80, you'll need to run the SocketCluster server with sudo node server -p 80.

For more info about SocketCluster, visit http://socketcluster.io/.

If you want to find out more about authentication and authorization, you may want to look into SC middleware: http://socketcluster.io/#!/docs/middleware-and-

To run the engine on multiple CPU cores, you just need to add more worker and broker processes. You can do this by adding extra parameters to the node server command (-w is the number of worker processes and -b is the number of broker processes):

node server -w 3 -b 1

Unless your CPU/OS is particularly efficient with multitasking, you generally want to have one process per CPU core (to avoid sharing cores/context switching penalties). Note that in the example above, we are launching 4 processes in total; 3 workers and 1 broker.

Deciding on the correct ratio of workers to brokers is a bit of a balancing act and will vary based on your specific workload - You will have to try it out and watch your processes. When you launch the engine, SocketCluster will tell you the PIDs of your worker and broker processes.

Based on the rudimentary tests that I've carried out so far, I've found that you generally need more workers than brokers. The ratio of workers to brokers that seems to work best for most use cases is approximately 2:1.

Also note that cell controllers (cell.js) will be evenly sharded across available workers. For this reason, it is highly recommended that you divide your world grid in such a way that your number of worker processes and total number of cells share a common factor. So for example, if you have 3 workers, you can have a world grid with dimensions of 3000 * 3000 pixels made up of 3 cells of dimensions 1000 * 3000 (rectangular cells are fine; in fact, I highly encourage them since they are more efficient).

More Info

It's still very early for this project, here are some things that still need improving:

  • The front end needs some sort of motion smoothing since we don't want to set the WORLD_UPDATE_INTERVAL too high (for bandwidth reasons) and so the animation should be smoothed out on the front end.
  • The front end needs an overall cleanup; maybe we need to move the core logic outside of index.html into its own .js file... And maybe we can start using the import statement (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) to load dependencies?
  • We need to make a custom SocketCluster codec specifically for this game engine to compress all outgoing messages to be as small as possible. Right now it's just using a general-purpose binary compression codec for SC - We should add another codec layer on top of this.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].