As part of my journey to learn about coding in HTML/JS/CSS, I decided to create a top-down shooter game. While I've successfully implemented player movement and rotation on the canvas, I'm struggling with getting the gun mechanics to work properly.
After following tutorials and searching through StackOverflow posts, I defined a variable 'gunfire' set to 1 when the left mouse button is pressed and 0 otherwise. My aim is to draw bullets in front of the sprite when the mouse button is clicked. However, the issue I'm facing is that the bullets appear regardless of the mouse input.
If anyone can help pinpoint the error in my code, I would greatly appreciate it. Here's the snippet (the canvas is created in separate HTML/CSS files):
// Your JavaScript code goes here