diff --git a/index.js b/index.js index 8586979..dc54a25 100644 --- a/index.js +++ b/index.js @@ -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); } @@ -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); @@ -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]; diff --git a/package.json b/package.json index cd7d53d..489548c 100644 --- a/package.json +++ b/package.json @@ -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/" diff --git a/src/entities/snake.js b/src/entities/snake.js index 305e059..f405d8b 100644 --- a/src/entities/snake.js +++ b/src/entities/snake.js @@ -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; @@ -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; - })(); \ No newline at end of file diff --git a/src/messages/direction.js b/src/messages/direction.js index 83c42ea..f5a6a6b 100644 --- a/src/messages/direction.js +++ b/src/messages/direction.js @@ -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; }; \ No newline at end of file diff --git a/src/messages/end.js b/src/messages/end.js index 45cbc18..2152f5e 100644 --- a/src/messages/end.js +++ b/src/messages/end.js @@ -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; }; diff --git a/src/messages/leaderboard.js b/src/messages/leaderboard.js index 24e62bd..359d6c8 100644 --- a/src/messages/leaderboard.js +++ b/src/messages/leaderboard.js @@ -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);