Cannon fire rate power up
![thelogobar](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
My player character is a static cannon, I wanted to have different power ups that change the rate the cannon reloads.
Problem is when a shell hits the power up that changes the reload time, the existing reload time has to count down before it starts reloading faster.
This is how its working at the moment:
Rules that dictate when the cannon can and can't fire 'game.no-fire' when this is false then the canon can fire. Once the canon has fired the 'game.fire' changes to true and a timer runs 'game.ReloadTime' that changes it back to false so the cannon can fire again.
So when the cannon ball hits a crate that contains a faster reload power up there is another rule that changes 'game.ReloadPowerUp' to a number. The cannon has some rules that "if game.ReloadPowerUp = 0 then game.ReloadTime = 4 seconds", and "if game.ReloadPowerUp = 1 then game.ReloadTime = 1 seconds" etc.
My problem is if the cannon is firing every 4 seconds, and the power up to make it reload every 1 second is hit. The cannon still runs the 4 second reload, until the next time it fires, then it runs every second for the specified amount of time the power up is set to run for.
Am I making sense?
Is there a simpler way of doing this?
Thanks!
Problem is when a shell hits the power up that changes the reload time, the existing reload time has to count down before it starts reloading faster.
This is how its working at the moment:
Rules that dictate when the cannon can and can't fire 'game.no-fire' when this is false then the canon can fire. Once the canon has fired the 'game.fire' changes to true and a timer runs 'game.ReloadTime' that changes it back to false so the cannon can fire again.
So when the cannon ball hits a crate that contains a faster reload power up there is another rule that changes 'game.ReloadPowerUp' to a number. The cannon has some rules that "if game.ReloadPowerUp = 0 then game.ReloadTime = 4 seconds", and "if game.ReloadPowerUp = 1 then game.ReloadTime = 1 seconds" etc.
My problem is if the cannon is firing every 4 seconds, and the power up to make it reload every 1 second is hit. The cannon still runs the 4 second reload, until the next time it fires, then it runs every second for the specified amount of time the power up is set to run for.
Am I making sense?
Is there a simpler way of doing this?
Thanks!
Best Answer
-
Cluv Posts: 229
You could use a table, or set up a power up check first. In other words, have a boolean or line of code that will skip the regular reload, if a power up is touched, and then in the otherwise section, place the regular reload time.
IF powerup touched
THEN reload based on powerup (reset boolean)
OTHERWISE
reload normal
I hope that helps!
Answers