Commit 8d318e06 authored by DoNaTio s.r.o.'s avatar DoNaTio s.r.o.
Browse files

ball.psd added

parent 28899859
......@@ -6,11 +6,12 @@
* @constructor
*/
function ClientCollision(Playground, Ball) {
function ClientCollision(Playground, Ball, Racket) {
var attributes = {
'ball': Ball,
'playground': Playground
'playground': Playground,
'racket': Racket
};
return {
......@@ -19,6 +20,14 @@ function ClientCollision(Playground, Ball) {
var ballVectors = attributes.ball.getVectors();
var playgroundDimension = attributes.playground.getDimension();
var racketVectors = attributes.racket.getVectors();
/**
* Racket collision
*/
if (ballAxis.y > playgroundDimension.h) {
ballVectors.vy = -ballVectors.vy;
......@@ -41,6 +50,7 @@ function ClientCollision(Playground, Ball) {
ballAxis.x = 0;
}
//console.log(ballVectors.vx, ballVectors.vy);
attributes.ball.setAxis(ballAxis.x, ballAxis.y);
attributes.ball.setVectors(ballVectors.vx, ballVectors.vy);
......
......@@ -21,6 +21,7 @@ $(function () {
var score = new ClientScore( $('.score') );
var ball = new ClientBall( $('#ball') );
var racket = new ClientRacket();
ball.setAxis(100,100);
......@@ -78,9 +79,10 @@ $(function () {
newLine.setAttribute('x2', endX);
newLine.setAttribute('y2', endY);
$("#map").html(newLine);
$('#map').fadeIn().delay(2000).fadeOut( "slow", function() {
$('#map').fadeIn().delay(20000).fadeOut( "slow", function() {
$("#map").html("");
});
racket.setVector(endX-startX, endY-startY);
});
// Whenever the server emits 'login', log the login message
......
function ClientRacket($el){
function ClientRacket(){
var attributes = {
'el': $el,
'el': '',
'vx': 0,
'vy': 0
};
return {
setEl: function(el){
attributes.el = el;
},
setVector : function(vx, vy){
attributes.vx = vx;
attributes.vy = vy;
},
getVector: function(){
return {
vx: attributes.vx,
vy: attributes.vy
}
}
}
}
......@@ -41,6 +41,7 @@
<div class="container">
<div id="playground">
<div id="table"></div>
<div class="rackets">
<div class="racket racket1"></div>
<div class="racket racket2"></div>
......@@ -51,9 +52,9 @@
</div>
<div class="score"><span class="team0">0</span>:<span class="team1">0</span></div>
<div id="ball"></div>
<svg id="map" width="968" height="776" version="1.1" xmlns="http://www.w3.org/2000/svg">
</svg>
<div id="table"></div>
<svg id="map" width="968" height="776" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
</div>
</div>
</div>
......
......@@ -128,7 +128,11 @@ body {
z-index: 2;
}
#map{
z-index: 9999;
}
line {
z-index: 9999;
stroke:rgb(1,1,1);
stroke-width:3;
}
\ No newline at end of file
Supports Markdown
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