I'm making a HTML5 Game with:
requestAnimationFrame || setInterval(updateGame(), 1E3 / 60)
Player(x,y, radius = 20) is a cirle. Bullet(x,y,bulletSpeed = 50).
Every Frame Bullet position increased 50px.
I have code calculator collision:
if(distance(Player,Bullet) <= Player.radius) Player.hp--, Bullet.remove();
But, because Bullet + 50px per frame, so Bullet across Player and keep moving (view image below).
How I can fix that?
Sorry about my English and Thanks for reading!