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

Programmer Humor

32410 readers
1 users here now

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

Rules:

founded 6 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] cookie_sabotage@sh.itjust.works 159 points 1 year 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.

[–] blarth@thelemmy.club 34 points 1 year ago (2 children)

Yay, escaped the fight with 0 health!

[–] andrew@lemmy.stuart.fun 5 points 1 year ago

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

load more comments (1 replies)
load more comments (16 replies)