Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Making a counter for every 5 increments.

$
0
0
Okay, I'm currently making a game, and the player has a level, and skills. What I want is for every 5 levels that the player gains, he gains a talent point that will effect one of his skills. Now I know that I could achieve this by doing a bunch of if statements, but I don't think that is the most efficient way to do it.

Here's an example off the top of my head:

if(level == 5){
talentpoints++;
}
if(level == 10){
talentpoints++;
}



I could easily implement it this way, but it seems redundant and kind of messy to say the least, and would also mean that there would be an eventual cap to talent points. What kind of counter could I implement to resolve this issue and make it more efficient?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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