Commit fcf15646 authored by Monika's avatar Monika
Browse files

display dynamically rackets

parent 253fa6fb
......@@ -87,9 +87,7 @@ $(function () {
if(data.id == 1){
user.setIsTurn(true);
}
for (var i=0; i < data.allIds.length; i++){// if we need later to send all players whe can directly from them take ids
$rackets.append("<div class='racket racket" + data.allIds[i] + "'></div>")
}
displayRackets(data);
racket.setEl($('div.racket' + data.id));
connected = true;
}
......@@ -120,6 +118,7 @@ $(function () {
log.add(data.username + ' joined');
log.add(data.username + ' is team ' + data.team);
user.setTeam(data.team);
displayRackets(data);
console.log(data);
});
......@@ -132,6 +131,12 @@ $(function () {
$('div.racket' + data.id).css({left: data.x, top: data.y});
}
function displayRackets(data){
for (var i=0; i < data.allIds.length; i++){// if we need later to send all players whe can directly from them take ids
$rackets.append("<div class='racket racket" + data.allIds[i] + "'></div>")
}
}
$('.logout').click(function () {
socket.emit('disconnectUser', user);
$gamePage.fadeOut();
......
......@@ -76,7 +76,8 @@ io.on('connection', function (socket) {
socket.broadcast.emit('user joined', {
username: newPlayer.getName(),
numUsers: PlayersCollection.getCount(),
team: newPlayer.getTeam()
team: newPlayer.getTeam(),
allIds: PlayersCollection.getIds()
});
socket.on('move racket', function (data) {
......
Supports Markdown
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