Skip to content

yoyosh/agario-client2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agario-client2

Client API for Agar.io v2

Installation

Sorry, no NPM package support, you can install it directly through Github:

npm install https://github.com/SNSA/agario-client2.git --save

Usage

const AgarClient = require('agario-client2');
const Client = AgarClient.Client;
const server = AgarClient.server;
const client = new Client('clientName');

client.on('connected', () => {
  console.log('Connected to server and ready to spawn'); 
  client.spawn('SNSA');
});

client.on('newBall', (data) => {
  console.log('New ball appears');
});

server.getFFAServer({}, (resp) => {
  if (resp.error) {
    return console.log('Error while getting FFA server:', resp.error);
  }
  console.log('Connecting to:', resp.server);

  client.connect('ws://' + resp.server);
});

API

Client

let client = new AgarClient.Client(clientName)

Client methods

  • client.connect(server): connect to Agar server, connect to the same ws://ip:port to join the same room
  • client.disconnect(): disconnect from Agar server
  • client.spawn(nickName): spawn a ball

Client events

In this list on.eventName(param1, param2) means you need to do client.on('eventName', function(param1, param2) { ... })

  • on.connected(): connected to server and ready to spawn
  • on.newBall(data: Buffer): new ball appears, sent when respawned or split (manually or by hitting a virus)
  • on.reset(): reset all balls, sent when start a new game
  • on.leaderBoard(data: Array): Leader board information, each item of the array is an array like [highlight, nickname], highlight is a number with value 0 or 1 where 1 means nickname should be highlighted in leader board (for example your nickname)
  • on.worldUpdate(data: Buffer): world update, contains all information needed to draw the visible cells

server

let server = AgarClient.server

See this.

License

MIT

About

Client API for Agar.io v2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%