Tyding code and Profile Pictures Animated

This commit is contained in:
Luis Fernando Molina committed 2018-04-22 17:12:39 +02:00
1 parent d381d1ef7b
commit ea6bce95c9
3 files changed
+80 -58

No files matched your search

+64 -54
View File
@@ -25,6 +25,62 @@ function newFloatingSpace() {
}
function createNewBall(pInput, pContainer) {
/* This function is used to create new balls, representing labels of each point on the chart. */
var ball = newBall();
ball.input = pInput;
ball.container = pContainer;
ball.friction = .995;
ball.initializeMass(15);
ball.initializeRadius(30);
ball.initializeImageSize(50);
ball.fillStyle = 'rgba(255, 255, 255, 0.5)';
ball.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
createdBalls.push(ball);
ball.handle = Math.floor((Math.random() * 10000000) + 1);
return ball.handle;
}
function destroyBall(pBallHandle) {
for (let i = 0; i < createdBalls.length; i++) {
let ball = createdBalls[i];
if (ball.handle === pBallHandle) {
createdBalls.splice(i, 1); // Delete item from array.
return;
}
}
for (let i = 0; i < thisObject.balls.length; i++) {
let ball = thisObject.balls[i];
if (ball.handle === pBallHandle) {
thisObject.balls.splice(i, 1); // Delete item from array.
return;
}
}
}
/******************************************/
/* */
/* Physics Engine Follows */
/* */
/******************************************/
function physicsLoop() {
/* This function makes all the calculations to apply phisycs on all balls in this space. */
@@ -65,6 +121,14 @@ function newFloatingSpace() {
ball.currentRadius = ball.currentRadius - .5;
}
// The imageSize also have a target.
if (ball.currentImageSize < ball.targetImageSize) {
ball.currentImageSize = ball.currentImageSize + 1;
} else {
ball.currentImageSize = ball.currentImageSize - 1;
}
/* Collision Control */
for (let k = i + 1; k < thisObject.balls.length; k++) {
@@ -117,60 +181,6 @@ function newFloatingSpace() {
}
}
function createNewBall(pInput, pContainer) {
/* This function is used to create new balls, representing labels of each point on the chart. */
var ball = newBall();
ball.input = pInput;
ball.container = pContainer;
ball.friction = .995;
ball.initializeMass(15);
ball.initializeRadius(30);
ball.fillStyle = 'rgba(255, 255, 255, 0.5)';
ball.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
createdBalls.push(ball);
ball.handle = Math.floor((Math.random() * 10000000) + 1);
return ball.handle;
}
function destroyBall(pBallHandle) {
for (let i = 0; i < createdBalls.length; i++) {
let ball = createdBalls[i];
if (ball.handle === pBallHandle) {
createdBalls.splice(i, 1); // Delete item from array.
return;
}
}
for (let i = 0; i < thisObject.balls.length; i++) {
let ball = thisObject.balls[i];
if (ball.handle === pBallHandle) {
thisObject.balls.splice(i, 1); // Delete item from array.
return;
}
}
}
/******************************************/
/* */
/* Physics Engine Follows */
/* */
/******************************************/
function gravityForce(ball) {
/* We simulate a kind of gravity towards the target point of each ball. This force will make the ball to keep pushing to reach that point. */