- Home /
Question by
Chazzwazzler · Nov 15, 2019 at 10:47 PM ·
integer
How do I get my project to sense when an integer has gone up by a certain amount?
In my game I want to get a boss fight to spawn every 50 points that I earn. I don't want to code an if statement for every 50 points, as my game is meant to last forever. How do I do this?
Comment
Best Answer
Answer by Hellium · Nov 15, 2019 at 10:47 PM
const int bossStep = 50;
int totalPoints = 0;
int nextBossThreshold = bossStep;
public void AddPoints(int points)
{
totalPoints += points;
if( totalPoints > nextBossThreshold )
{
nextBossThreshold += bossStep;
// Trigger boss fight
}
}