How to a dynamic hunger/health icon

This code will show a dynamic image based on the sprite sheet:

The health starts at 10, and decreases with each click