A Question about Global Integers.

Started by Global Lint, Wed 20/01/2010 18:10:34

Previous topic - Next topic

Global Lint

Hello all.

Imagine, if you will, a turn-based game with hit points as global int's.

The player has 60 hit points.
The enemy character performs an action that removes 100 hit points from the player's hp gauge.

If, in the script, the game was meant to 'end' (run a previously written 'game over' script) when the player's hp reached zero--

--would the global int become -40 or would it stop at zero to run the 'game over' script?

Just curious.
Spaz ate the dopefish.

Calin Leafshade

the ints are signed so it would happily go into negative numbers.. Just check to see if it is less than 1 instead of zero.

or clamp the int when he loses the health in the first place.

NsMn

If it would check the points repeatedly and it isn't possible to, for example, get from 5 to -20 points, yes. But since that is probablynot the case, I'll just shut up.

SMF spam blocked by CleanTalk