diff --git a/src/entities/sector.coffee b/src/entities/sector.coffee new file mode 100644 index 0000000..70c395b --- /dev/null +++ b/src/entities/sector.coffee @@ -0,0 +1,7 @@ +module.exports = +class Sector + ### + Section: Construction + ### + constructor: (@foods) -> + # .. \ No newline at end of file diff --git a/src/messages/direction.coffee b/src/messages/direction.coffee index 37f59ba..c6ba4cb 100644 --- a/src/messages/direction.coffee +++ b/src/messages/direction.coffee @@ -12,12 +12,17 @@ exports.build = (id, direction) -> ## Append message type b += message.writeInt8 b, arr, type - ## Append id + ## Append snake id b += message.writeInt16 b, arr, id - ## Append position values - b += message.writeInt8 b, arr, direction - b += message.writeInt8 b, arr, 71 - b += message.writeInt8 b, arr, 104 + ### + Append position values + @todo Sending this makes conflict with the normal movement + of the snake. Probably due to a bad calculation of the direction parameters. + + b += message.writeInt8 b, arr, direction.angle + b += message.writeInt8 b, arr, direction.x + b += message.writeInt8 b, arr, direction.y + ### arr diff --git a/src/messages/snake.coffee b/src/messages/snake.coffee index 8146e90..df99b8d 100644 --- a/src/messages/snake.coffee +++ b/src/messages/snake.coffee @@ -13,33 +13,43 @@ exports.build = (snake) -> b += message.writeInt8 b, arr, 0 b += message.writeInt8 b, arr, type + + ## Append snake id b += message.writeInt16 b, arr, snake.id + + ## Append snake stop param b += message.writeInt24 b, arr, snake.D + ## Append unknown b += message.writeInt8 b, arr, 0 + ## Append possible angles of the snake b += message.writeInt24 b, arr, snake.X + + ## Append snake speed b += message.writeInt16 b, arr, snake.speed - b += message.writeInt24 b, arr, 0.028860630325116536 * 16777215 + + ## Unkown + b += message.writeInt24 b, arr, 0 + + ## Append snake skin b += message.writeInt8 b, arr, snake.skin + + ## Append spawn body positions b += message.writeInt24 b, arr, snake.body.x b += message.writeInt24 b, arr, snake.body.y + ## Append name b += message.writeInt8 b, arr, nameLength + b += message.writeString b, arr, snake.name - message.writeString b, arr, snake.name - - index = b + nameLength - message.writeInt24 index, arr, snake.head.x - message.writeInt24 index + 3, arr, snake.head.y - index += 6 + b += message.writeInt24 b, arr, snake.head.x + b += message.writeInt24 b, arr, snake.head.y i = 0 while i < snake.parts.length - message.writeInt8 index, arr, snake.parts[i].x - message.writeInt8 index + 1, arr, snake.parts[i].y - - index += 2 + b += message.writeInt8 b, arr, snake.parts[i].x + b += message.writeInt8 b, arr, snake.parts[i].y i++ diff --git a/src/server.coffee b/src/server.coffee index b409da9..d98f2b8 100644 --- a/src/server.coffee +++ b/src/server.coffee @@ -121,7 +121,7 @@ class Server conn.snake.body.x += Math.cos((Math.PI / 180) * conn.snake.direction.angle) * 170 conn.snake.body.y += Math.sin((Math.PI / 180) * conn.snake.direction.angle) * 170 - @broadcast directionMessage.build(conn.snake.direction.angle) + @broadcast directionMessage.build(conn.snake.id, conn.snake.direction) @broadcast movementMessage.build(conn.snake.id, conn.snake.direction.x, conn.snake.direction.y) # Pong