Getting your player to move around the screen requires event listeners for keydown events (pressing down on your keyboard). Once you learn how to listen for specific keys, you can react to these events and force your player to move by altering its velocity. This video will teach you exactly that and a few other techniques such as keeping your player confined to the visible area of your screen.
If you look closely at the projectiles when the player is moving very fast they are spawning behind the current position of the player.
My Fix is to also add the player.velocity so that the projectile spawns from the next frame which is the then current position of the player.
window.addEventListener("click", e => { const angle = Math.atan2(e.clientY - player.y + player.velocity.y, e.clientX - player.x + player.velocity.x); const velocity = { x: Math.cos(angle) * 5, y: Math.sin(angle) * 5 }; projectiles.push(new Projectile(player.x + player.velocity.x, player.y + player.velocity.y, 5, 'white', velocity)); });