Code Monkey home page Code Monkey logo

agar.io-clone's Introduction

Agar.io Clone

This project was originally created by @huytd. I have since taken ownership of the repository to revive the project.

GitHub Stars GitHub Issues GitHub Wiki Live Demo Gitter

A simple but powerful Agar.IO clone built with socket.IO and HTML5 canvas on top of NodeJS.

Image

Live Demos

An updated live list of demos can be found on the Live Demos wiki page.

The official Agar.IO-Clone URL can be found here.

This is the most up to date version from master. Any merged pull requests will deploy to this URL automatically.


How to Play

You can check out how to play on our wiki.

Game Basics

  • Move your mouse around the screen to move your cell.
  • Eat food and other players in order to grow your character (food respawns every time a player eats it).
  • A player's mass is the number of food particles eaten.
  • Objective: Try to get as big as possible and eat other players.

Gameplay Rules

  • Players who haven't eaten yet cannot be eaten as a sort of "grace" period. This invincibility fades once they gain mass.
  • Everytime a player joins the game, 3 food particles will spawn.
  • Everytime a food particle is eaten by a player, 1 new food particle will respawn.
  • The more food you eat, the slower you move to make the game fairer for all.

Latest Changes

  • Game logic is handled by the server
  • The client side is for rendering of the canvas and its items only.
  • Mobile optimisation.
  • Implementation of working viruses.
  • Display player name.
  • Now supporting chat.
  • Type-ping in the chatbox to check your ping, as well as other commands!

Installation

You can simply click one of the buttons below to easily deploy this repo to Bluemix or Heroku:

Deploy to Heroku

Or...

You can check out a more detailed setup tutorial on our wiki.

Requirements

To run / install this game, you'll need:

  • NodeJS with NPM installed.
  • socket.IO.
  • Express.

Downloading the dependencies

After cloning the source code from Github, you need to run the following command to download all the dependencies (socket.IO, express, etc.):

npm install

Running the Server

After downloading all the dependencies, you can run the server with the following command:

npm start

The game will then be accessible at http://localhost:3000. The default port is 3000, however this can be changed in config. Further elaboration is available on our wiki.

Running the Server with Docker

If you have Docker installed, after cloning the repository you can run the following commands to start the server and make it acessible at http://localhost:3000:

docker build -t agarioclone_agar .
docker run -it -p 3000:3000 agarioclone_agar

FAQ

  1. What is this game?

This is a clone of the game Agar.IO. Someone said that Agar.IO is a clone of an iPad game called Osmos, but we haven't tried it yet. (Cloneception? :P)

  1. Why would you make a clone of this game?

Well, while the original game is still online, it is closed-source, and sometimes, it suffers from massive lag. That's why we want to make an open source version of it: for educational purposes, and to let the community add the features that they want, self-host it on their own servers, have fun with friends and more.

  1. Any plans on adding an online server to compete with Agar.IO or making money out of it?

No. This game belongs to the open-source community, and we have no plans on making money out of it nor competing with anything. But you can of course create your own public server, let us know if you do so and we can add it to our Live Demos list!

  1. Can I deploy this game to my own server?

Sure you can! That's what it's made for! ;)

  1. I don't like HTML5 canvas. Can I write my own game client with this server?

Of course! As long as your client supports WebSockets, you can write your game client in any language/technology, even with Unity3D if you want (there is an open source library for Unity to communicate with WebSockets)!

  1. Can I use some code of this project on my own?

Yes you can.

For Developers

TODOs

We have an explicit TODO list for the all the features we aim to develop in the future. Feel free to contribute, we'll be more than grateful.

License

You can check out the full license here.

This project is licensed under the terms of the MIT license.

agar.io-clone's People

Contributors

aadilzbhatti avatar abalabahaha avatar bjarneo avatar coderjoew avatar comus avatar cschwarz avatar espressobit avatar francisco-maciel avatar huytd avatar igorantun avatar incognitov avatar jniles avatar joemattie avatar jonaslsaa avatar jsloyer avatar juhq avatar juslee avatar kbariotis avatar madarauchiha avatar owenashurst avatar peterdavehello avatar sarencurrie avatar saviosg avatar scoolnik avatar themuddfamily2 avatar vikramdurai avatar villers avatar vytorcalixto avatar wb9688 avatar zoldszemesostoros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agar.io-clone's Issues

Hit test: NaN ยฑ 10

When starting a game i can see my red dot, but as soon as i move my cursor the server says "Hit test: NaN ยฑ 10" and the food dots begin to appear.

Unit Testing

It's time to talk about unit testing.
I used Jasmine for many of my previous project so I choose Jasmine.
If you got any better idea (mocha/chai or something, idk), please suggest.

Add virus

It's time to add some virus to the game.
My idea is:

  • The virus will be in violet color (#9b59b6 for filling color, #9b50ba for border color)
  • Virus also has it's own mass
  • Virus can be feed to get more mass (become larger)
  • Player will be exploded if he has bigger size than the virus (and he eat it)

More idea?

Proper source code structure

Shouldn't the code be more structured? What about adding some .editorconfig file and linting/hinting? Would you accept such PRs?

Problem with hosting C9

Hi, I have a problem with the configuration of Agar Clone on Cloud9 (c9.io). I installed everything, I configured IP and port (0.0.0.0), but after starting the application error pops up:

TypeError: Cannot read property 'name' of undefined
at Socket. (/home/ubuntu/workspace/server/server.js:152:44)
at Socket.emit (events.js:95:17)
at Socket.emit (/home/ubuntu/workspace/node_modules/socket.io/lib/socket.js:129:10)
at Socket.onclose (/home/ubuntu/workspace/node_modules/socket.io/lib/socket.js:418:8)
at Client.onclose (/home/ubuntu/workspace/node_modules/socket.io/lib/client.js:230:12)
at Socket.emit (events.js:117:20)
at Socket.onClose (/home/ubuntu/workspace/node_modules/socket.io/node_modules/engine.io/lib/socket.js:248:10)
at WebSocket.g (events.js:180:16)
at WebSocket.emit (events.js:92:17)
at WebSocket.Transport.onClose (/home/ubuntu/workspace/node_modules/socket.io/node_modules/engine.io/lib/transport.js:113:8)

In addition, I give a private message to log data hosting, in order to help. Have you some free hosting to test it yourself to calm the game engine? Thanks in advance for any help! :)

Getting literally 2 FPS

I've tried multiple different servers, even the demo, Im pretty sure its due to my bad computer or the network usage, just thought I'd put this as a bug as I do not lag on agar.

Menu Feature?

a menu that you can choose your name can be very cool.

Should create Players and Player object

Should create Players and Player object.

Players should be initialized once to hold all players object. It should also have all the methods related to findPlayer, getPlayersList etc.

The Player object should have the x, y etc. And it should probably inherit the playerConfig. This object should be initialized in socket.on("welcome", function(us

Perhaps it also should be packed in webpack, so the code could be shared on the client and server side?

Thoughts?

Spiky 4s in names

If a player's name includes a 4, then it renders with a spike above it. See screenshot. Size varies dependant on cell mass. Not critical, just strange.

screenshot

Invisible Players & out-of-sync player counter

Seeming randomly, after playing with 15 people, the largest person went invisible, you could clearly see him eating the food particles as he approached, then you get disconnected as he reached you.
Also, once somebody has died, the player counter loses count somehow, showing 13 when 15 players were clearly visible.

I'm investigating these now.

Player name shouldn't grow with cell size

The usernames are growing as you eat more food. That shouldn't happen (unless name fits entirely on cell size, perhaps?)

As it is right now, even if your name overflows the cell size, it'll continue to get bigger as your cell does.

Fire a food

Press W or something to fire yourself as a food. To feed other player or virus.

Adding animations?

I'm thinking about adding an animation engine for handling some animation (split animation,...) and for faster HitTest.

But have no idea where should we calculate the animation. On server side (more complex) or on client side (much easier? any risk?)

EDIT: Appended #134

"... noticed when you eat the "food" the transition between your current size and the next size is instantaneous. Could you add the transition of the "expansion" from your current size to the new size?"

Add new chat type (bubble)

Linked with #3
It's better to have another chat style (bubble)
And we need to make a switch somewhere (config/setting page) to allow user switch between chat type.

Problem with new config system

i am getting a lot of problems with the new config system,

problems like this:

npm ERR! [email protected] postinstall: `./node_modules/bower/bin/bower install && cp server/config.dist.yml server/config.yml`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the agar-clone package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./node_modules/bower/bin/bower install && cp server/config.dist.yml server/config.yml
npm ERR! You can get their info via:
npm ERR!     npm owner ls agar-clone
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.14.13-c9
npm ERR! command "/home/ubuntu/.nvm/v0.10.35/bin/node" "/home/ubuntu/.nvm/v0.10.35/bin/npm" "install"
npm ERR! cwd /home/ubuntu/workspace
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ubuntu/workspace/npm-debug.log
npm ERR! not ok code 0

the yml is the problem?

Can't eat each other

Hi,
we are using firefox on fedora and arch linux and we can not eat each other.
it does not matter who is larger, we can not eat the smaller one.
sometimes we can not even see each other

Add a LICENSE

Adding a license (MIT seems like it would fit the project best) lets a contributor know how their code will be used in the future. Could you add one?

Server being spammed

The server is flooding the game console when a player moves and/or a food has been eaten.

Bad Server/Client Communication Architecture ?

1. player's move need server feedback

first, player send playerSendTarget command to server.
then server got it, calculate the new position, and send back the serverTellPlayerMove command to this player.

after the server feedback, the player can move.

If there is a big lag between player and server,
the player move will be blocked in a long time.

This should be player move first, then got the server feedback,
player modify it's position with the server feedback data.

2. The server broadcast message immediately

when a player move mouse,
the server will got a playerSendTarget command, and target data.

server do some calculate (eat food, or eat other players),
then broadcast serverUpdateAllPlayers to all connected players.

This is a bad design.

If there are 100 players connected to the server.
every player move mouse one times per second.

It means, the server will broadcast 100 times in one seconds.
And every client will got 100 times messages.

This is very overload to both server and client.

This should be done as the follows:

Server has a tick rate (maybe 10Hz. 10 times per second) to sync the whole game world to all clients.
(AOI. (area of interest ) are just ignored right now )

player send playerSendTarget to server immediately.
server do calculate, and NOT broadcast the message to other clients.

When next server tick comes, then send serverUpdateAllPlayers to all clients.

This can avoid the overload of server and client in a high rate communicate.
Server To Client rate is Fixed to the server tick rate.

"node server/server.js" or "npm start" is not working

I have all packages (NPM,Socket,Bower, etc.). I think that I installed all of requires correctly. But I get an error like;

root@xxx:~/agar.io-clone# npm start

[email protected] start /root/agar.io-clone
node server/server.js

Config file not found!

When I try to write "node server/server.js"

root@sinankose:~/agar.io-clone# node server/server.js
-bash: /usr/sbin/node: No such file or directory

Both are not working, what should I do?

Limit area size?

Maybe should be limit area size X x X in settings?
Now I can travel unlimited away from others...

Add a chat

So we can express our anger when people eat us.

Grid background

We should draw a grid to background to see if player is moving or not when there are no foods on screen

Connection refused

I get connection refused whenever I run this, I have reinstalled the server 3-4 times now and I am still getting this error, thanks. there are no errors appearing at all it just says "listening on port :3000" here is the server I am running it on http://23.94.96.14:3000/

Add team mode

maybe even where you can choose which team to join, so playing 6 vs 6 on your local lan party is possible

Let newbies be eaten?

I think newbies should be allowed to be eaten. I feel it makes the game more fun when you start you have to work your way up

Issue assigment

Please assign yourself to whatever issue you want solve. I want to contribute but I dont know on which one peaple are currently working.

Cell speed

Cell should have an invisible radius with a fixed size around it that controls its speed. Currently it's pretty annoying that when you reach the window border your cell slows down dramatically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.