Float vs integer

Hi, is there a reason why are we using float for hitpoints/damage and not just integers? Seems much cleaner to me as I can be sure that I wont end up with a float of 0,000001 for example and with the enemy being still alive…
Thanks
Laco

It’s a design decision. Much like players having 100 health when every enemy does 10 damage. That is the same as giving a player 10 health and having enemies do 1 damage, but more satisfying.

With some games, enemies do 10 damage and that’s that. But in other games, there are modifiers to damage. Like the sword of smiting that does 10% more damage to undead creatures. 10% of 10 is 1, but 10% of 12 is 1.2. You don’t want to lose that 0.2 point of damage. So, we use floats and round the displayed value.

If you want to use ints for your health, nothing is stopping you. It’s your game and you can do what you want with it

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms