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
40579e29
Commit
40579e29
authored
Dec 05, 2014
by
DoNaTio s.r.o.
Browse files
fix collision
parent
82b84156
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/ClientCollision.js
View file @
40579e29
...
...
@@ -6,7 +6,7 @@
* @constructor
*/
function
ClientCollision
(
Playground
,
Ball
){
function
ClientCollision
(
Playground
,
Ball
)
{
var
attributes
=
{
'
ball
'
:
Ball
,
...
...
@@ -14,34 +14,34 @@ function ClientCollision(Playground, Ball){
};
return
{
collision
:
function
(){
collision
:
function
()
{
var
ballAxis
=
attributes
.
ball
.
getAxis
();
var
ballVectors
=
attributes
.
ball
.
getVectors
();
var
playgroundDimension
=
attributes
.
playground
.
getDimension
();
if
(
ballAxis
.
y
>
playgroundDimension
.
h
)
{
if
(
ballAxis
.
y
>
playgroundDimension
.
h
)
{
ballVectors
.
vy
=
-
ballVectors
.
vy
;
ballAxis
.
y
=
playgroundDimension
.
h
;
attributes
.
ball
.
setAxis
(
ballAxis
.
x
,
ballAxis
.
y
);
}
else
if
(
ballAxi
s
.
y
<
0
)
{
else
if
(
ballAxis
.
y
<
0
)
{
ballVector
s
.
v
y
=
-
ballVectors
.
vy
;
ballAxis
.
y
=
0
;
}
// If ball strikes the vertical walls, invert the
// x-velocity vector of ball
if
(
ballAxis
.
x
>
playgroundDimension
.
w
)
{
if
(
ballAxis
.
x
>
playgroundDimension
.
w
)
{
ballVectors
.
vx
=
-
ballVectors
.
vx
;
ballAxis
.
x
=
playgroundDimension
.
w
;
}
else
if
(
ballAxis
.
x
<
0
)
{
else
if
(
ballAxis
.
x
<
0
)
{
ballVectors
.
vx
=
-
ballVectors
.
vx
;
ballAxis
.
x
=
0
;
}
attributes
.
ball
.
setAxis
(
ballAxis
.
x
,
ballAxis
.
y
);
attributes
.
ball
.
setAxis
(
ballAxis
.
x
,
ballAxis
.
y
);
attributes
.
ball
.
setVectors
(
ballVectors
.
vx
,
ballVectors
.
vy
);
}
...
...
public/style_boot.css
View file @
40579e29
...
...
@@ -90,7 +90,6 @@ body {
}
#playground
{
padding
:
100px
;
background-color
:
silver
;
background
:
url(images/parkety.jpg)
;
width
:
968px
;
...
...
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