Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
89944abc
Commit
89944abc
authored
Dec 09, 2014
by
Monika
Browse files
edges playground - racket
parent
0a73c89a
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/ClientMain.js
View file @
89944abc
...
...
@@ -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
...
...
public/ClientPlayer.js
View file @
89944abc
...
...
@@ -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
;
}
}
}
Write
Preview
Markdown
is supported
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