Closed tyilo closed 11 years ago
Another example:
var Test = function(io) {
var r = 25;
var a = 0.1;
var s = 50;
var s0;
//var v = 0;
var ball;
function onBottom(ball) {
ball.vel.y *= -0.9;
if(ball.pos.y > s0) {
ball.pos.y = s0;
}
if(-ball.vel.y < ball.acc.y) {
ball.acc.y = -ball.vel.y;
}
return true;
}
function init() {
s0 = io.canvas.height - r;
//var v0 = Math.sqrt(v * v - 2 * a * (s - s0));
ball.setBound('bottom', s0 + r, onBottom);
ball.acc.y = a;
}
this.onResize = init;
ball = io.addObj(new iio.ioCircle(io.canvas.center.x, s, r)
.setFillStyle('blue')
.enableKinematics()
.setAcc(0, a));
init();
io.setFramerate(60);
};
iio.start(Test);
Very cool, thanks for the demos. I have merged this feature into the Git distribution, but I did it by hand because I wanted to modify some of the statements and I also just reorganized the structure of the git repo and didn't want to deal with all the deletions.
I'll put up some demos and docs about this feature soon. Thanks!
Added acceleration support for kinematics.
Example code: