Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DoNaTio s.r.o.
PiPo
Commits
fcf15646
Commit
fcf15646
authored
Dec 11, 2014
by
Monika
Browse files
display dynamically rackets
parent
253fa6fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/ClientMain.js
View file @
fcf15646
...
...
@@ -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
();
...
...
server.js
View file @
fcf15646
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment