Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
josip committed Dec 17, 2011
0 parents commit b943ce0
Show file tree
Hide file tree
Showing 361 changed files with 44,434 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app.js
@@ -0,0 +1,34 @@
var io = require('socket.io'),
express = require('express'),
colour = require('onecolor'),
app = express.createServer();

app.configure(function () {
app.use(express.static(__dirname + '/static'));
});

function hsv2hex(h, s, v) {
return (new colour.HSV(h/360, s/100, v/100)).hex()
}

var commands = {
join: function (req) { return { id: Math.random().toString(16).split('.')[1],
colour: hsv2hex(Math.ceil(Math.random()*1000)%360, 80, 92)} },
leave: function (req) { return {id: req.param('id')} },
move: function (req) { return {id: req.param('id'), direction: req.param('d')} }
};

app.get('/player/:command', function (req, res) {
var command = req.param('command'),
resp = commands[command](req);

sio.sockets.in('screen').emit(command, resp);
res.json(resp);
});

app.listen(80);
var sio = io.listen(app);

sio.sockets.on('connection', function (socket) {
socket.join('screen');
});
1 change: 1 addition & 0 deletions node_modules/.bin/express

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/express/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b943ce0

Please sign in to comment.