
Untitled
By: a guest on
Jun 15th, 2012 | syntax:
JavaScript | size: 0.66 KB | hits: 25 | expires: Never
function jump() {
var time = 0;
var velocity = 50;
var startpos = 1;
var acceleration = -20;
console.log("start jump");
startpos = startpos + (velocity * time) + (Math.pow(acceleration * time, 2) / 2);
if (startpos >= archery && time != 0) {
down = true;
ctx.clearRect(0, 0, c.width, c.height);
ctx.drawImage(archer, archerx, archery);
ctx.drawImage(square, squarex, squarey);
} else {
ctx.clearRect(0, 0, c.width, c.height);
ctx.drawImage(archer, archerx, (archery - startpos));
ctx.drawImage(square, squarex, squarey);
}
if (!down) {
time += 1;
timerID = self.setTimeout("jump()", delayJump);
} else {
down = false;
}
}