Commit 89944abc authored by Monika's avatar Monika
Browse files

edges playground - racket

parent 0a73c89a
......@@ -55,6 +55,15 @@ $(function () {
x: event.pageX - $playground.offset().left,
y: event.pageY - $playground.offset().top
};
if(user.getTeam() == 0 && d.x < $playground.width() / 2){
d.x = $playground.width() / 2;
}
if(user.getTeam() == 1 && d.x > $playground.width() / 2){
d.x = $playground.width() / 2;
}
racket.setAxis(event.pageX - $playground.offset().left,event.pageY - $playground.offset().top);
drawRacket(d)
socket.emit('move racket', d);
......@@ -112,6 +121,7 @@ $(function () {
socket.on('user joined', function (data) {
log.add(data.username + ' joined');
log.add(data.username + ' is team ' + data.team);
user.setTeam(data.team);
});
// Whenever the server emits 'user left', log it in the chat body
......
......@@ -13,6 +13,7 @@ function ClientPlayer(dom){
'inputEl': dom.find('.usernameInput'),
'signedInEl': dom.find('#signedInAs'),
'isTurn': false,
'team' : 0,
'loginCallback': function(){}
};
......@@ -48,6 +49,12 @@ function ClientPlayer(dom){
},
setLoginCallback:function(callback){
attributes.loginCallback = callback;
},
setTeam: function(team){
attributes.team = team;
},
getTeam: function(){
return attributes.team;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment