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
259429a5
Commit
259429a5
authored
Dec 18, 2014
by
DoNaTio s.r.o.
Browse files
fix reflection
parent
7f0bc29f
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/ClientCollision.js
View file @
259429a5
...
...
@@ -65,13 +65,16 @@ function ClientCollision(Ball, Racket, User) {
vR
=
racketVector
,
//vektor rakety
vL
=
ballVectors
;
// vektor lopticky
var
nvR
=
this
.
normalize
(
vR
);
var
vL2
=
this
.
reflect
(
vL
,
nvR
);
attributes
.
ball
.
setVectors
(
vL2
.
x
,
vL2
.
y
);
if
(
vL2
.
x
==
0
&&
vL2
.
y
==
0
)
{
attributes
.
ball
.
setVectors
(
1
,
1
);
if
(
vL
.
vx
==
0
&&
vL
.
vy
==
0
)
{
var
nvR
=
this
.
normalize
(
vR
);
attributes
.
ball
.
setVectors
(
nvR
.
vx
,
nvR
.
vy
);
}
else
{
var
nvR
=
this
.
normalize
(
vR
);
var
vL2
=
this
.
reflect
(
vL
,
nvR
);
attributes
.
ball
.
setVectors
(
vL2
.
x
,
vL2
.
y
);
}
console
.
log
(
ballVectors
,
'
ball
'
);
console
.
log
(
attributes
.
racket
.
getAttributes
(),
'
getAttributes
'
);
console
.
log
(
racketVector
,
'
racketVector
'
);
...
...
public/ClientRacket.js
View file @
259429a5
...
...
@@ -50,7 +50,7 @@ function ClientRacket() {
getVector
:
function
()
{
// console.log(attributes.x - attributes.prevX, attributes.y - attributes.prevY, 'lala');
return
{
vx
:
attributes
.
prevX
-
attributes
.
x
,
vx
:
attributes
.
x
-
attributes
.
prevX
,
vy
:
attributes
.
y
-
attributes
.
prevY
}
}
...
...
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