Quantcast
Channel: Answers by "Flynn"
Viewing all articles
Browse latest Browse all 59

Answer by Flynn

$
0
0
function ammoPickedUp (ammoPickUp : int) { if (ammoMG <= 200){ ammoMG += ammoPickUp; } } Let's walk through this. If you have 199 bullets left, and you ask it to add ten, then first, it will check if 199 is below 200. 199 is. It will then add 10, resulting in 209 bullets. To fix this, instead write your function like this: function ammoPickedUp (ammoPickUp : int) { ammoMG += ammoPickUp; ammoMG += 200 - ammoMG; //if ammoMG is ten higheer than 200, 200-210 will result in negative ten. Adding a negative number causes it to go down by ten. Making it 200 }

Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>