this post was submitted on 28 Mar 2024
615 points (98.1% liked)

Programmer Humor

32472 readers
564 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 159 points 7 months ago (18 children)
public class GameManager : MonoBehaviour
{
    public bool EnableHighContrast;
    public bool PlayerWon;
    public float PlayerUnitsMoved;
    public int PlayerDeathCount;
    public float PlayerHealth;

    public void PlayerTakeDamage(float damage)
    {
        PlayerHealth -= damage;
        if (PlayerHealth < 0)
        {
            PlayerDieAndRespawn();
        }
    }

    public void PlayerDieAndRespawn()
    {
        return;
    }
}

I couldn't contain myself.

[–] [email protected] 34 points 7 months ago (2 children)

Yay, escaped the fight with 0 health!

[–] [email protected] 15 points 7 months ago

Well if you have a "down but not dead" condition then yes, you could escape a fight with 0 health (assuming you have teammates/pawns that can save you).

[–] [email protected] 5 points 7 months ago

This is floating point. We also need to know what happens when you escape with -0.

load more comments (15 replies)