1
Graphics / Re: How can i slow down the rate my projectiles fire.
« on: May 03, 2017, 09:32:19 am »
Analysing solely the code you posted. Here's how it reads to me.
For every monster, check every tower to see if they're in range. If they are in range, Create a bullet at so and so position.
I think therein lies your issue. You're creating a new bullet every time you check collision(presumably every frame).
In my opinion, I would create a shoot() method in your tower class. If a monster is in range, call this method, but dont spawn a bullet right away. Have a local clock, and check to see that it's past a certain time before actually spawning a new bullet. Most important, when you spawn a new bullet, you need to ::reset() the clock, or it'll auto fire exactly like I think you're seeing now.
For every monster, check every tower to see if they're in range. If they are in range, Create a bullet at so and so position.
I think therein lies your issue. You're creating a new bullet every time you check collision(presumably every frame).
In my opinion, I would create a shoot() method in your tower class. If a monster is in range, call this method, but dont spawn a bullet right away. Have a local clock, and check to see that it's past a certain time before actually spawning a new bullet. Most important, when you spawn a new bullet, you need to ::reset() the clock, or it'll auto fire exactly like I think you're seeing now.