This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start: -> | |
@loop() | |
@gameLoop = setInterval @loop, 100 | |
loop: => | |
switch @state | |
when Game.STATES.WAITING, Game.STATES.RESTARTING | |
@checkIfGameStarts() | |
when Game.STATES.COUNTDOWN | |
@countdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buffer = -> | |
buf = new Buffer(arguments.length ? 0) | |
buf.writeUInt8(arguments[index], index) for index in [0...arguments.length] | |
buf | |
module.exports = buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buffer = -> | |
buf = new Buffer(arguments.length ? 0) | |
for index in [0...arguments.length] | |
buf.writeUInt8(arguments[index], index) | |
buf | |
beer = buffer(0xF0, 0x9F, 0x8D, 0xBA) | |
process.stdout.write beer | |
console.log '\ndone!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 3 | |
y = 5 | |
blankRowSpaces = (y-1) * process.stdout.columns | |
blankColSpaces = (x-1) | |
rows = ('' for i in [1..blankRowSpaces]).join(' ') | |
cols = ('' for i in [1..blankColSpaces]).join(' ') | |
process.write rows | |
process.write cols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.on 'data', (data)-> | |
console.log "data = #{data}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.setRawMode true | |
process.stdin.resume() | |
process.stdin.on 'data', @onData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createGame = (attributes, server)-> | |
game = new Game(attributes) | |
game.addListener 'game', server.onGameChange | |
game.addListener 'stopped', server.onGameStopped | |
game.start() | |
game | |
class Server | |
constructor: (attributes={})-> | |
@gameFactory = attributes.createGame ? createGame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClientGameSocket | |
constructor: (@socket, @game, @cycle)-> | |
@socket.on 'movement', @onMovement | |
@socket.on 'disconnect', @onLeave | |
@socket.on 'leave', @onLeave | |
@socket.join @game.name | |
@socket.emit 'cycle', @cycle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onGameChange: (game)=> | |
@io.sockets.in(game.name).emit 'game', game.toJSON() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "vimtronner", | |
"version": "0.0.9", | |
"description": "A multi-player Vim trainer.", | |
"main": "lib/vimtronner.js", | |
..., | |
"dependencies": { | |
"socket.io": "", | |
"socket.io-client": "", | |
"commander": "", |
OlderNewer