Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
10765aa
continue hacking variable names
fxia22 Jun 20, 2015
499ab8d
add upload code
fxia22 Jun 20, 2015
09628fa
Merge branch 'master' of https://github.com/Eureka22/agar-clone
fxia22 Jun 20, 2015
5d74616
merge
fxia22 Jun 20, 2015
0bb380e
add readme
fxia22 Jun 20, 2015
d8bf80f
Update README.md
fxia22 Jun 20, 2015
3a9c37f
Update README.md
fxia22 Jun 20, 2015
c3c8184
1
fxia22 Jun 20, 2015
d5e8132
merge
fxia22 Jun 20, 2015
0951c4e
hack variable
fxia22 Jun 20, 2015
5986732
var
fxia22 Jun 20, 2015
c055af9
var
fxia22 Jun 20, 2015
931c0a0
fix bug
fxia22 Jun 20, 2015
546853d
Readability improved
m-byte Jun 20, 2015
446f8a7
Added custom text mode for leaderboard.
m-byte Jun 21, 2015
d20ee27
More cleanup
m-byte Jun 21, 2015
6a3ace0
Function updateNodes() is mostly cleaned up
m-byte Jun 21, 2015
8a3deac
Code improved
m-byte Jun 21, 2015
8b43b85
Automatic formatting
m-byte Jun 21, 2015
9887638
Refactoring
m-byte Jun 21, 2015
dc72d88
Got rid of most comma expressions
m-byte Jun 21, 2015
435e0b3
Comma expressions all gone
m-byte Jun 21, 2015
12dcdd5
Merge pull request #1 from m-byte/master
fxia22 Jun 21, 2015
cff80f7
Reverted 6a3ace0, as it introduced an error
m-byte Jun 21, 2015
990f815
Merge pull request #2 from m-byte/master
fxia22 Jun 21, 2015
401b184
Neater version of updateNodes. This time tested and working...
m-byte Jun 21, 2015
d83022a
Merge pull request #3 from m-byte/master
fxia22 Jun 21, 2015
d28d547
local
fxia22 Jun 21, 2015
2605ded
merge
fxia22 Jun 21, 2015
05bab54
var
fxia22 Jun 21, 2015
b72a23d
Update readme
fxia22 Jun 21, 2015
6f4801c
revert to 05bab54 due to a bug
fxia22 Jun 21, 2015
9a6c501
readme
fxia22 Jun 21, 2015
618cd9b
Merge pull request #1 from Eureka22/master
m-byte Jun 21, 2015
dfea991
Changed the value of package 255 to 1332175218 (ASCII for "Ogar") an…
m-byte Jun 21, 2015
2cc9f84
fix bug
fxia22 Jun 21, 2015
bb15d79
Documented protocol extensions
m-byte Jun 21, 2015
0ab57f6
var
fxia22 Jun 21, 2015
2d19c51
Merge remote-tracking branch 'origin/master'
m-byte Jun 21, 2015
35aff2b
Merge pull request #2 from Eureka22/master
m-byte Jun 21, 2015
e2d0612
Merge pull request #5 from m-byte/master
fxia22 Jun 21, 2015
0fd807f
ignore ide files
fxia22 Jun 21, 2015
a1df150
Update PROTOCOL.md
fxia22 Jun 22, 2015
a7d727c
Update README.md
fxia22 Jun 22, 2015
0838b68
refactor
fxia22 Jun 22, 2015
da2022f
refactor
fxia22 Jun 22, 2015
50d2b83
refactor
fxia22 Jun 22, 2015
a96177c
clan support
fxia22 Jun 22, 2015
991987c
remove console log
fxia22 Jun 22, 2015
b32ebef
index
fxia22 Jun 22, 2015
3d4387d
Merge branch 'master' of https://github.com/Eureka22/agar-clone
fxia22 Jun 22, 2015
0d53649
update index
fxia22 Jun 22, 2015
6e93390
Update readme
fxia22 Jun 23, 2015
2ff7e1e
Update README.md
fxia22 Jun 23, 2015
5588f36
Update README.md
fxia22 Jun 23, 2015
ae0dad1
add branch
fxia22 Jun 24, 2015
f9337d6
add
fxia22 Jun 24, 2015
238931e
fix
fxia22 Jun 24, 2015
5d5bb6c
Update README.md
fxia22 Jun 24, 2015
28365e6
Update README.md
fxia22 Jun 24, 2015
12fbaa6
Update README.md
fxia22 Jun 24, 2015
c5faf11
Merge pull request #9 from Eureka22/web-server
fxia22 Jun 24, 2015
77a1916
Update PROTOCOL.md
fxia22 Jun 24, 2015
c33591b
fix a bug
fxia22 Jun 24, 2015
059f306
refactor
fxia22 Jun 24, 2015
68836e9
fix bug
fxia22 Jun 24, 2015
03eae12
Update README.md
fxia22 Jun 24, 2015
01f3e7f
fix bug
fxia22 Jun 24, 2015
be57ed7
fix bug
fxia22 Jun 24, 2015
fac3e1e
fade
fxia22 Jun 24, 2015
0cd469f
resize problem
fxia22 Jun 24, 2015
bbe25f3
fix bug
fxia22 Jun 25, 2015
e362af9
Merge pull request #3 from Eureka22/master
m-byte Jun 25, 2015
76ac364
addChat changed to new protocol
m-byte Jun 25, 2015
c893480
sendChat changed to new protocol
m-byte Jun 25, 2015
33ede0d
PROTOCOL.md changed to new protocol
m-byte Jun 25, 2015
0ee8a73
Added note regarding packet 48
m-byte Jun 25, 2015
d58c34f
Fixed protocol documentation
m-byte Jun 25, 2015
a532f96
Merge pull request #10 from m-byte/master
fxia22 Jun 25, 2015
a8457d1
gallery
fxia22 Jun 26, 2015
374b93b
gallery
fxia22 Jun 26, 2015
07c2357
resize
fxia22 Jun 26, 2015
ea10611
resize
fxia22 Jun 26, 2015
4dbf9d9
Merge pull request #4 from Eureka22/master
m-byte Jun 27, 2015
ab142f4
Update README.md
m-byte Jun 27, 2015
e788fd9
Merge pull request #14 from m-byte/master
fxia22 Jun 27, 2015
7e9c260
Support sub domains for servers
m-byte Jun 27, 2015
afe5a4a
Remove stuff that redirects to or depends on the official servers. On…
m-byte Jun 27, 2015
9961e5b
Merge pull request #15 from m-byte/master
fxia22 Jun 27, 2015
5068f36
fix super big chat
fxia22 Jun 28, 2015
dbbab0b
close #18
fxia22 Jun 28, 2015
0a7cbbb
close #18
fxia22 Jun 28, 2015
eedbeb0
mobile comtrol
fxia22 Jun 28, 2015
c45aae4
Update README.md
fxia22 Jun 28, 2015
ac09d5d
forget picture
fxia22 Jun 28, 2015
35539cc
-
fxia22 Jun 28, 2015
8771f23
fix bug
fxia22 Jun 28, 2015
372501e
minor tweak
fxia22 Jun 28, 2015
c03985e
fix imagename space bug
fxia22 Jun 28, 2015
bad0507
fix spectate bug
fxia22 Jun 28, 2015
8d0fbd1
fix bug
fxia22 Jun 29, 2015
a2c53f5
toggle chat, close #25
fxia22 Jun 29, 2015
1b2240d
welcome page resize close #24
fxia22 Jun 29, 2015
3e5d40a
Merge pull request #1 from Eureka22/master
vram4 Jun 29, 2015
ff16fff
Implement smooth rendering of cells
vram4 Jun 29, 2015
397b3f8
Merge pull request #26 from vram4/master
fxia22 Jun 29, 2015
f446db7
Im retarded
vram4 Jun 29, 2015
e7df132
Merge pull request #28 from vram4/master
vram4 Jun 29, 2015
0c0716c
add initial resize
fxia22 Jun 30, 2015
41af5ae
add initial resize
fxia22 Jun 30, 2015
42d46a5
Update README.md
fxia22 Jun 30, 2015
e240a1d
fix a random bug
fxia22 Jun 30, 2015
4bbca4c
fix a random bug
fxia22 Jun 30, 2015
9ca796b
Update README.md
m-byte Jul 15, 2015
5d24e14
Update index.html
Jul 16, 2015
646e603
Update index.html
Jul 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.png
.idea/*
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/agar-clone.iml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

322 changes: 0 additions & 322 deletions .idea/workspace.xml

This file was deleted.

32 changes: 32 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# PROTOCOL

## Protocol extensions
As the server has to tell whether the client supports protocol extensions, the values of package 254 and 255 have been adjusted.
Package 255 now contains "Ogar" in ASCII (1332175218) while package 254 contains the version number. When modifying the protocol,
only new features can be implemented. Also, the client must be compatible with older versions of the server.

## Changes
Please document any changes introduced here. Direction has to be either `S2C` (server to client) or `C2S`.

### Version 1


| Direction | ID | Value | Description|
| :------------ |:---------------| :-----|:----|
|C2S | 254 | 1 | Version number|
|C2S | 255 | 1332175218 | String "Ogar" - Tells the server how to use the modified protocol|
|S2C | 48 | behaves like #49 | Leaderboard without numbers|
|C2S | 99 | flags (uint8) [1], message | For in-game chat, each char is in Uint16 |
|S2C | 99 | flags (uint8) [1], r (uint8), g (uint8), b (uint8), nick, '\0', message, '\0' | same as above |

[1] If flags has the 2, 4, or 8 bit set, an offset of 4, 8, or 16 bytes follows before any other data. Until these additional
bytes are used, just skip them.

Hint : to use Packet 48, make sure the packet ID in case 48 of Ogar/src/packet/UpdateLeaderboard.js is adjusted like this:
```
view.setUint8(0, this.packetLB, true);
```
You can also use https://github.com/m-byte/Ogar, which already has this feature enabled.

### Version 2
TODO: We could add chat functionality in this version. That way, only one websocket server would be needed.
68 changes: 66 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
# agar-clone
clone of agar.io

You can use nginx to deploy it on your server.
## Contents
- [Introduction](#introduction)
- [Setup](#setup)
- [Test and Known Issues](#test-and-known-issues)
- [FAQ](#faq)
- [Protocol Extensions](#protocol-extensions)
- [Contributions](#contributions)
- [Disclaimer](#disclaimer)

## Introduction

This is a clone of agar.io. In this project we aim to acheive the following.

- [x] Hack main_out.js and make the variables and function names readable. Now most of the variable and function name should make sense.
- [x] Add uploading custom skins features (Done)
- [x] Add [in-game chat](https://cloud.githubusercontent.com/assets/5158896/8327532/c41e94fa-1a9b-11e5-87cc-f42b5f6ef2df.png) feature. (Done)
- [x] Add mobile device support (Done)
- [x] Support multi-server feature (Done in Cigar)

##Setup

Copy all files to a server with PHP support (e.g. LEMP/LAMP). To check whether your server supports PHP, please read [this tutorial](http://www.cyberciti.biz/faq/how-do-i-test-php-installation-with-a-phpinfo-page/).
Once everything is set up, open index.html in your browser. If everything is working well, go to the next section to use your own Ogar server.

### Support Your Server
Replace the CONNECTION_URL with your own ip and port in main_out.js

### Upload Custom Skins
The upload module does two things. The first is to upload a skin onto skins folder. The second is that the client request the server to run checkdir.php every 15 seconds to check what skins are uploaded and add them into knownNameDict. Then the skins can be loaded.

To make this feature work, you need to give upload.php priviliage to read skins folder.


```
chmod 777 skins
```

will make it work.



## Test and Known Issues

This client has been tested on LEMP stack on OS X 10.10 and Ubuntu 14.04 with server side [Ogar](https://github.com/vram4/Ogar).

It is known that some of the variables and function names still make no sense, we are working on that.

## FAQ
### Can agar-clone connect to the official server?
No, agar-clone is not intended to be used with the official server. You will have to use it with [Ogar](https://github.com/forairan/Ogar) or [Cigar](https://github.com/m-byte/Cigar).

### How can I use the chat feature?
Currently, only [Cigar](https://github.com/m-byte/Cigar) supports the chat protocol. If you know of another server supporting the extended protocol, feel free to [let us know](https://github.com/Eureka22/agar-clone/issues).

## Protocol extensions
As the server has to tell whether the client supports protocol extensions, the values of package 254 and 255 have been adjusted.
Package 255 now contains "Ogar" in ASCII (1332175218) while package 254 contains the version number. When modifying the protocol,
only new features can be implemented. Also, the client must remain compatible with older versions of the server.

Original protocol can be found [here](https://github.com/vram4/Agar.io-Protocol). Changes to the protocol have to be [documented](PROTOCOL.md).

## Contributions

Pull Request are welcome.

## Disclaimer

Note that the aim of this repo is to study agar.io client, understand the mechanism and find potential improvements. It is worth pointing out that hosting a third-party agar client is against the [Terms](http://agar.io/terms.txt) of Agario and not recommended by the owner of this repo. Please think twice before hosting the client and do it at your own risk. :)
121 changes: 121 additions & 0 deletions Vector2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
var Vector2 = function(x, y) {
this.x = x || 0;
this.y = y || 0;
};
Vector2.prototype = {
reset: function(x, y) {
this.x = x;
this.y = y;
return this;
},
toString: function(decPlaces) {
decPlaces = decPlaces || 3;
var scalar = Math.pow(10, decPlaces);
return "[" + Math.round(this.x * scalar) / scalar + ", " + Math.round (this.y * scalar) / scalar + "]";
},
clone: function() {
return new Vector2(this.x, this.y);
},
copyTo: function(v) {
v.x = this.x;
v.y = this.y;
},
copyFrom: function(v) {
this.x = v.x;
this.y = v.y;
},
magnitude: function() {
return Math.sqrt((this.x * this.x) + (this.y * this.y));
},
magnitudeSquared: function() {
return (this.x * this.x) + (this.y * this.y);
},
normalise: function() {
var m = this.magnitude();
this.x = this.x / m;
this.y = this.y / m;
return this;
},
reverse: function() {
this.x =- this.x;
this.y =- this.y;
return this;
},
plusEq: function(v) {
this.x += v.x;
this.y += v.y;
return this;
},
plusNew: function(v) {
return new Vector2(this.x + v.x, this.y + v.y);
},
minusEq: function(v) {
this.x -= v.x;
this.y -= v.y;
return this;
},
minusNew: function(v) {
return new Vector2(this.x - v.x, this.y - v.y);
},
multiplyEq: function(scalar) {
this.x*=scalar;
this.y*=scalar;
return this;
},
multiplyNew: function(scalar) {
var returnvec = this.clone();
return returnvec.multiplyEq(scalar);
},
divideEq: function(scalar) {
this.x/=scalar;
this.y/=scalar;
return this;
},
divideNew: function(scalar) {
var returnvec = this.clone();
return returnvec.divideEq(scalar);
},
dot: function(v) {
return (this.x * v.x) + (this.y * v.y);
},
angle: function(useRadians) {
return Math.atan2(this.y, this.x) * (useRadians ? 1 : Vector2Const.TO_DEGREES);
},
rotate: function(angle, useRadians) {
var cosRY = Math.cos(angle * (useRadians ? 1 : Vector2Const.TO_RADIANS));
var sinRY = Math.sin(angle * (useRadians ? 1 : Vector2Const.TO_RADIANS));
Vector2Const.temp.copyFrom(this);
this.x = (Vector2Const.temp.x * cosRY) - (Vector2Const.temp.y * sinRY);
this.y = (Vector2Const.temp.x * sinRY) + (Vector2Const.temp.y * cosRY);
return this;
},
equals: function(v) {
return ((this.x == v.x) && (this.y == v.x));
},
isCloseTo: function(v, tolerance) {
if (this.equals(v))
return true;
Vector2Const.temp.copyFrom(this);
Vector2Const.temp.minusEq(v);
return (Vector2Const.temp.magnitudeSquared() < tolerance * tolerance);
},
rotateAroundPoint: function(point, angle, useRadians) {
Vector2Const.temp.copyFrom(this);
Vector2Const.temp.minusEq(point);
Vector2Const.temp.rotate(angle, useRadians);
Vector2Const.temp.plusEq(point);
this.copyFrom(Vector2Const.temp);
},
isMagLessThan: function(distance) {
return (this.magnitudeSquared() < distance * distance);
},
isMagGreaterThan: function(distance) {
return (this.magnitudeSquared() > distance * distance);
}
};
Vector2Const = {
TO_DEGREES: 180 / Math.PI,
TO_RADIANS: Math.PI / 180,
temp: new Vector2()
};

21 changes: 21 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html>
changes are recorded in this document


<head>
<meta charset="UTF-8">
</head>
<br/>
日常更新(June 22):

<br/>
1.
更新了客户端,请大家帮忙测试,如果有问题请告诉我。考完试增加更多特性请期待。
<br/>

2. 更新了"部落模式", 如果使用[部落名]用户名 例如"[526a]李小花","[ee]Richard
Song" 之类的id, 会使用中括号里的名字作为皮肤, 玩家可以上传皮肤。
预告: 近期将开启皮肤图片库功能,另外上传和背景色相同的图片将会被禁止。
<br/>

</html>
Binary file added feed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading