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

Programmer Humor

32483 readers
530 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
[–] cookie_sabotage@sh.itjust.works 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.

[–] wise@feddit.uk 57 points 7 months ago (10 children)

Should it be

PlayerHealth <= 0

?

Otherwise the player could have 0 health and not die? I’m sleep deprived so forgive me if I’m wrong

[–] bassomitron@lemmy.world 27 points 7 months ago (2 children)
[–] wise@feddit.uk 54 points 7 months ago (1 children)

Counting this meme as my first FOSS contribution

[–] SidewaysHighways@lemmy.world 12 points 7 months ago

Holy shit I was there with you sir! With the zeros and stuff

load more comments (7 replies)
load more comments (14 replies)