HaikuBotStalksMe

HaikuBotStalksMe t1_itseyy7 wrote

That's a fair point. But like usually overflow or underflows in games happen because you didn't bother setting up a safe upper or lower bound.

Like in 8 bits, you're gonna get up to 255. As such, I wouldn't let someone have more than like 200 points, and no single action will allow them to gain more than 50 points. And each time they gain or lose, I'm gonna make sure that if the value will be negative, then they can only go to 0 ("if score < pointslost: score = 0; else score -= pointslost"), and if adding any score goes over 200, then the score is set to 200.

My coworkers complain I overthink/over-safety my code sometimes, but hey, why risk it?

4

HaikuBotStalksMe t1_itqy3ug wrote

This kind of stuff is why I program safety measures in my game. Like "if x == 0, do blah. If x == 2, do blah2, if x==3 do blah 3. If x > 3, x= 3 continue, if x < 0, x = 0, continue"

10