--- a/client/js/tweetvote-anim.js Tue Feb 21 11:10:12 2012 +0100
+++ b/client/js/tweetvote-anim.js Tue Feb 21 11:26:01 2012 +0100
@@ -292,13 +292,13 @@
setInterval(function() {
- // Check if
+ // Check if div podiums are already loaded
if($('#podium div').size() > 0) {
$('#podium div').each( function(idx, panel) {
var idxWall = 5+idx;
- var yWall = 945-$(this).height();
+ var yWall = 920-$(this).height();
world.DestroyBody(walls[idxWall]);
walls[idxWall] = createBox(world, 580+370*idx, yWall, 170, 10);
@@ -311,9 +311,6 @@
function createBallTweetForce(t) {
- var xpos = 40;
- var ypos = 70;
-
var element = document.createElement( 'div' );
element.width = 96;
element.height = 96;
@@ -338,27 +335,26 @@
var offset = (48 - BALL_SIZE)/2;
var graphics = circle.getContext('2d');
- graphics.fillStyle = "white";
- graphics.beginPath();
- graphics.arc(BALL_SIZE* .25+10, BALL_SIZE* .25, BALL_SIZE* .25, 0, PI2, true);
- graphics.closePath();
- graphics.fill();
+ graphics.fillStyle = "white";
+ graphics.beginPath();
+ graphics.arc(BALL_SIZE* .25+10, BALL_SIZE* .25, BALL_SIZE* .25, 0, PI2, true);
+ graphics.closePath();
+ graphics.fill();
graphics.fillStyle = "#E2F0D6";
graphics.beginPath();
graphics.arc(BALL_SIZE * .5 +offset+24, BALL_SIZE * .5+offset+14, BALL_SIZE * .20, 0, PI2, true);
graphics.closePath();
graphics.fill();
-
var img = new Image();
img.src = t.profile_image_url;
img.onload = function(){
-
+
+ // Resize image
var canvasCopy = document.createElement("canvas");
var copyContext = canvasCopy.getContext("2d");
-
canvasCopy.width = 96;
canvasCopy.height = 96;
copyContext.drawImage(img, 0, 0, 96, 96);
@@ -366,10 +362,9 @@
var ptrn = graphics.createPattern(canvasCopy,'no-repeat');
graphics.fillStyle = ptrn;
graphics.fill(-5,0,150,150);
-
}
- element.appendChild( circle );
+ element.appendChild(circle);
text = document.createElement( 'div' );
text.onSelectStart = null;
@@ -379,6 +374,7 @@
text.style.top = '0px';
text.style.fontFamily = 'Georgia';
text.style.textAlign = 'center';
+ text.id = t.id_str;
element.appendChild(text);
var circle = new b2CircleDef();
@@ -386,40 +382,48 @@
circle.density = 1;
circle.friction = 0.3;
circle.restitution = 0.3;
-
- var b2body = new b2BodyDef();
- b2body.AddShape(circle);
- b2body.userData = {element: element};
- b2body.position.Set( xpos, ypos);
-
- var a, b;
+
+ var a, b, xpos, ypos;
switch (t.cat) {
case 0: // 1
a = 150;
b = -100;
+ xpos = 40;
+ ypos = 90;
break;
case 1: // 2
a = 250;
b = -150;
+ xpos = 40;
+ ypos = 70;
break;
case 2: // 3
a = 350;
b = -100;
+ xpos = 40;
+ ypos = 70;
break;
case 3: // 4
a = 390;
b = -180;
+ xpos = 40;
+ ypos = 70;
break;
-
default:
a = 390;
b = -180;
- console.log("default impulse!");
+ xpos = 40;
+ ypos = 70;
+ console.log("DEFAULT IMPULS PARAMS! Should not be there..");
break;
-
}
+ var b2body = new b2BodyDef();
+ b2body.AddShape(circle);
+ b2body.userData = {element: element};
+ b2body.position.Set( xpos, ypos);
+
b2body.linearVelocity.Set(a, b);
b2bod[t.id_str] = world.CreateBody(b2body);
console.log("created " + t.id_str)