I downloaded a couple of Javascript tutorials about 'Baasic physics', and i'm stuck on page 1.
Note. I have done a bit more research and think i understand most of it, but i can't work out what the symbols marked in red mean?
// Version 3 - Basic collision (viewbox), perfectly elastic (no energy loss)
var ball = {
x: 300,
y: 200,
r: 15,
vx: 0,
vy: 0
}
// Update ball (with Physics! =)
// 1 - apply velocity to position (vx -> x)
ball.x += ball.vx;
ball.y += ball.vy;
// 2 - apply drag/friction to velocity
ball.vx *= .99;
ball.vy *= .99;
// 3 - apply gravity to velocity
ball.vy += .25;
// 4 - check for collisions
if (ball.y + ball.r > canvas.height) {
ball.y = canvas.height - ball.r;
ball.vy = -Math.abs(ball.vy);
}
// Draw ball
ctx.save();
ctx.translate(ball.x, ball.y);
ctx.fillStyle = "#fff";
ctx.beginPath();
ctx.arc(0, 0, ball.r, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.restore();
}, 1000 / 77);
please could somebody have a look at the above and post a quick line breakdown.
thanks in advance.