easier bouncing

This commit is contained in:
James B. Pollack 2015-11-09 19:18:19 -08:00
parent 1ec70e8170
commit 789f3231e1

View file

@ -29,7 +29,6 @@ var grid = [
];
easystar.setGrid(grid);
easystar.setAcceptableTiles([0]);
@ -40,6 +39,7 @@ easystar.findPath(0, 0, 8, 0, function(path) {
Script.update.disconnect(tickEasyStar);
} else {
print('path' + JSON.stringify(path));
convertPath(path);
Script.update.disconnect(tickEasyStar);
}
@ -79,6 +79,16 @@ var playerSphere = Entities.addEntity({
linearDamping: 0.2
});
Script.setInterval(function(){
Entities.editEntity(playerSphere,{
velocity:{
x:0,
y:4,
z:0
}
})
},1000)
var sphereProperties;
//for keeping track of entities
@ -187,12 +197,8 @@ function updatePosition() {
x: currentSpherePosition.z,
y: sphereProperties.position.y,
z: currentSpherePosition.x
},
velocity: {
x: 0,
y: velocityShaper.y,
z: 0
}
});
}
@ -227,19 +233,9 @@ function createTweenPath(convertedPath) {
stepTweens[j].chain(stepTweens[j + 1]);
}
var velocityUpTween = new TWEEN.Tween(velocityShaper).to(upVelocity, ANIMATION_DURATION).onUpdate(updatePosition);
var velocityDownTween = new TWEEN.Tween(velocityShaper).to(noVelocity, ANIMATION_DURATION).onUpdate(updatePosition);
velocityUpTween.chain(velocityDownTween);
velocityDownTween.chain(velocityUpTween);
velocityUpTween.easing(TWEEN.Easing.Linear.None)
velocityDownTween.easing(TWEEN.Easing.Back.InOut)
//start the tween
//start the tween
stepTweens[0].start();
velocityUpTween.start();
}
var velocityShaper = {