function update() { ctx.strokeStyle = ctx.fillStyle = '#fff'; UpdatePhysics(loop.physicsStep); Collide(bodyA, bodyB, BodiesCollided); // Run this after all collision request // have been done. UpdateCollisions(); if (bodyA.position.y < 0) { bodyA.position.x = canvas.width / 2; bodyA.position.y = canvas.height; bodyA.velocity.x = 0; bodyA.velocity.y = 0; } if (bodyB.position.y > 512) { bodyB.position.x = canvas.width / 2; bodyB.position.y = -bodyB.collider.height; bodyB.velocity.x = 0; bodyB.velocity.y = 0; } }
function update() { UpdatePhysics(loop.physicsStep); }