A question about For Loops

Hi,

Did you test your idea? Does it work? If so, it’s a solution. :slight_smile:

Generally, if the compiler does not complain when you write code, you can do [insert your idea]. If your code solves your problem, that’s a different question.

What I want to do is that every 3000 points you gain a life. If this is not the way to do it, what would be the best alternative?

I would not use a for-loop for that. Somewhere in your code, you add points to a variable. When you add points, you could directly check the value of the variable. If it is a multiple of 3000, you add a life. Use an if-statement and look up modulo on DotNetPerls. That should help you implement your idea but this will work only if the player gets exactly 3000, 6000, etc. points. If they don’t, you will have to rethink your logic to come up with a solution for your problem.


See also:

1 Like