Skip to content

Commit

Permalink
First Runnable Release
Browse files Browse the repository at this point in the history
Thanks to cswl for helping me fix the error!
  • Loading branch information
RowanHarley authored Jun 17, 2016
1 parent 9b3067a commit a1c71ab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ function handleMessage(conn, data) {
y: 21137.4 * 5
}, skin);
broadcast(messages.snake.build(conn.snake));
var move = messages.movement.build(conn.id, conn.snake.direction.x, conn.snake.direction.y)
var move = messages.movement.build(conn.id, conn.snake.direction.x, conn.snake.direction.y);
var dir = messages.direction.build(conn.id, conn.snake.direction);
console.log("[DEBUG] A new snake called " + conn.snake.name + " was connected!");
spawnSnakes(conn.id);
conn.snake.update = setInterval((function() {
conn.snake.body.x += Math.round(Math.cos(conn.snake.direction.angle * 1.44 * Math.PI / 180) * 170);
conn.snake.body.y += Math.round(Math.sin(conn.snake.direction.angle * 1.44 * Math.PI / 180) * 170);
// This is where the error is coming from:
broadcast(dir);
broadcast(move);
}), 230);
Expand Down Expand Up @@ -174,12 +175,13 @@ function send(id,data){
function broadcast(data){
/* "use strict";
for(let client in clients){
if(client != null){
if(client){
client.send(data, {binary: true});
}
} */
for(var i = 0; i < clients.length; i++){
if(clients[i]){
console.log("[TEST] " + data);
clients[i].send(data, {binary:true});
}
}
Expand Down
4 changes: 2 additions & 2 deletions 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.2-b2",
"description": "A Server for Slither.io",
"version": "0.0.2",
"repository": {
"type": "git",
"url": "https://github.com/RowanHarley/Slither-Server/"
Expand Down
2 changes: 1 addition & 1 deletion src/entities/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = Snake = (function() {
this.speed = 5.79 * 1e3;
this.head = this.body;
this.D = 5.69941607541398 / 2 / Math.PI * 16777215;
this.X = D;
this.X = this.D;
this.length = 10;
this.J = 306;
this.I = 0.7810754645511785 * 16777215;
Expand Down
2 changes: 2 additions & 0 deletions src/messages/initial.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ b += message.writeInt16(b, arr, 0.028 * 1e3);
b += message.writeInt16(b, arr, 0.43 * 1e3);

b += message.writeInt8(b, arr, 8);

module.exports = arr;

0 comments on commit a1c71ab

Please sign in to comment.