Skip to content

Commit

Permalink
Upgraded to 0.0.5b2
Browse files Browse the repository at this point in the history
  • Loading branch information
RowanHarley authored Jun 28, 2016
1 parent 1428cf9 commit fa4d73e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ function handleMessage(conn, data) {
console.log("Snake in normal mode");
} else if (value === 254) {
console.log("Snake in speed mode");
//killPlayer(conn.id, 1);
messages.end.build(2);
} else if (value === 251) {
send(conn.id, messages.pong);
}
Expand Down Expand Up @@ -123,7 +125,7 @@ function handleMessage(conn, data) {
messages.end.build(0);
conn.close();
}
//broadcast(messages.position.build(conn.id, conn.snake.body.x, conn.snake.body.y));
broadcast(messages.position.build(conn.id, (conn.snake.body.x / 5), (conn.snake.body.y / 5)));
broadcast(messages.direction.build(conn.id, conn.snake.direction));
broadcast(messages.movement.build(conn.id, conn.snake.direction.x, conn.snake.direction.y));
}), 230);
Expand Down Expand Up @@ -193,6 +195,9 @@ function broadcast(data){
}
}
}
function killPlayer(playerId, endType){
broadcast(messages.end.build(endType));
}
function setMscps(mscps) {
fmlts = [mscps + 1 + 2048];
fpsls = [mscps + 1 + 2048];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Slither-Server",
"description": "A Server for Slither.io",
"version": "0.0.5b1",
"version": "0.0.5b2",
"repository": {
"type": "git",
"url": "https://github.com/RowanHarley/Slither-Server/"
Expand Down
7 changes: 4 additions & 3 deletions src/entities/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = Snake = (function() {
this.direction = {
x: 1,
y: 1,
angle: 0
angle: ((0.033 * 1e3) * 0 * this.scang * this.spang)
};
this.parts = [];
var i = 0;
Expand All @@ -33,8 +33,9 @@ module.exports = Snake = (function() {
});
i += 2;
}
this.sc = Math.min(6, 1 + (this.parts.length - 2) / 106.0);
this.scang = 0.13 + 0.87 * Math.pow((7 - this.sc) / 6 , 2);
this.spang = Math.min(this.speed / (4.8 * 10), 1);
}

return Snake;

})();
2 changes: 1 addition & 1 deletion src/messages/direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ exports.build = function(id, direction) {
b += message.writeInt16(b, arr, id);
b += message.writeInt8(b, arr, direction.angle);
b += message.writeInt8(b, arr, 104);
b += message.writeInt8(b, arr, 0);
b += message.writeInt8(b, arr, 1);
return arr;
};
2 changes: 2 additions & 0 deletions src/messages/end.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ exports.build = function(endNum){
b += message.writeInt8(b, arr, 'v'.charCodeAt(0));
// 0-2; 0 is normal death, 1 is new highscore of the day, 2 is unknown
b += message.writeInt8(b, arr, endNum);

return arr;
};

3 changes: 0 additions & 3 deletions src/messages/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ exports.build = function(rank, players, top) {
var player = top[i];
length += player.snake.name.length;
}
console.log("[RANK] " + rank);
console.log("[PLAYERS] " + players);
console.log("[TOP] " + top);
arr = new Uint8Array((8 + length) + (top.length * 7));
var b = 0;
b += message.writeInt8(b, arr, 0);
Expand Down

0 comments on commit fa4d73e

Please sign in to comment.