Commit 3130d324 authored by DoNaTio s.r.o.'s avatar DoNaTio s.r.o.
Browse files

Merge remote-tracking branch 'origin/newbranch' into newbranch

Conflicts:
	public/ClientCollision.js
	public/ClientMain.js
parents 5fc42995 a148ce14
......@@ -29,6 +29,12 @@ function ClientBall($el) {
y:attributes.y
};
},
getWidth: function() {
return attributes.width;
},
getHeight: function() {
return attributes.height;
},
getVectors: function(){
return {
vx:attributes.vx,
......
......@@ -40,16 +40,15 @@ function ClientCollision(Ball, Racket, User) {
var racketVector = attributes.racket.getVector();
var racketAxis = attributes.racket.getAxis();
var racketDimension = attributes.racket.getDimension();
console.log(attributes.user.getIsTurn());
/**
* Racket collision
*/
if (
attributes.user.getIsTurn()
//attributes.user.getIsTurn()
//&&
(ballAxis.x > racketAxis.x && ballAxis.x < racketAxis.x + racketDimension.width) //x coordinate
&&
(ballAxis.x > racketAxis.x && ballAxis.x < (racketAxis.x + racketDimension.width) ) //x coordinate
&&
(ballAxis.y < racketAxis.y && ballAxis.y > (racketAxis.y - racketDimension.height) ) //y coordinate
(ballAxis.y < racketAxis.y && ballAxis.y > racketAxis.y - racketDimension.height) //y coordinate
) {
console.log('collision ball with racket');
var BD = racketAxis, // bod dotyku (poz. lopticky)
......
......@@ -65,7 +65,7 @@ $(function () {
d.x = playgroundHalf;
}
racket.setAxis(event.pageX - $playground.offset().left, event.pageY - $playground.offset().top);
racket.setAxis(event.pageX - $playground.offset().left,event.pageY - $playground.offset().top);
drawRacket(d);
socket.emit('move racket', d);
......
......@@ -7,7 +7,8 @@ function ClientRacket() {
'prevX': 0,
'prevY': 0,
'x': 0,
'y': 0
'y': 0,
'isActive': false
};
return {
......@@ -22,19 +23,29 @@ function ClientRacket() {
'height': attributes.height
}
},
setAxis: function (x, y) {
attributes.prevX = attributes.x;
attributes.prevY = attributes.y;
setPrevAxis: function(x, y) {
attributes.prevX = x;
attributes.prevY = y;
console.log(x, y);
},
setAxis: function(x, y) {
attributes.x = x;
attributes.y = y;
},
getAxis: function () {
getAxis: function() {
return {
'x': attributes.x,
'y': attributes.y
}
},
setIsActive: function(isActive) {
attributes.isActive = isActive;
},
getIsActive: function() {
return attributes.isActive;
},
getVector: function () {
console.log(attributes.x - attributes.prevX, attributes.y - attributes.prevY, 'lala');
return {
vx: attributes.x - attributes.prevX,
vy: attributes.y - attributes.prevY
......
......@@ -63,6 +63,7 @@ body {
width: 30px;
height: 30px;
z-index: 99999;
border:1px solid silver;
}
.racket0 {
......@@ -130,6 +131,7 @@ body {
left: 100px;
background: url(images/ball.png) no-repeat;
z-index: 2;
border:1px solid red;
}
#map{
......
......@@ -77,7 +77,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) {
......
Markdown is supported
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