Day 4 of my Developer Journey: Fire rate and cleaning up

--

After the lase behavior was set up, I decided to set up a fire rater for the player as it does not make sense for us to be able to fire as many times as we can press the space bar.

So, this required 2 new variables, _fireRate and _nextFire. _fireRate is how much of a delay is happening between shots, _nextFire is the monitoring variable making sure that time has passed.

Our new variables

We achieve this by adding the value of _fireRate to the real time that has passed in game to _nextFire every time we shoot a bullet.

The calculator for when to fire

Then I fixed up my method to instantiate bullets and made it its own void method.

The New Method we call

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response