Skip to content
Advertisement

how to stop polygons from drawing between two moving circles in javascript

I am trying to make an html canvas game.I currently have a blue player in the middle of the screen that shoots projectiles. when i have two projectiles shot at once, a polygon is drawn between them. this confuses me, I AM using context.clearRect. I have tried using context.clearRect twice and i have also tried using bullets.splice to take the bullet out of the array when it is off the screen. how do i fix this? my code:

html:

JavaScript

js:

JavaScript

css:

JavaScript

EDIT: video of what happens

Advertisement

Answer

In the update() function add

JavaScript

After this line

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement