this post was submitted on 10 Feb 2026
294 points (95.4% liked)

Programmer Humor

29671 readers
785 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] ZILtoid1991@lemmy.world 1 points 16 hours ago* (last edited 12 hours ago) (1 children)

Now someone needs to make it an entity component system!

Attempt 1:

public struct Entity {
  bool isDog : 1;
  bool isAircraftCarrier : 1;
  bool isFlea : 1;
  bool canFlyInAir : 1;
  ubyte opt_numOfAircrafts : 4;
  int entityID;
  int opt_parentID;
  static Entity createDog(int entityID) {
    Entity result;
    result.isDog = true;
    result.entityID = entityID;
    return result;
  }
  static Entity createFlea(int entityID) {
    Entity result;
    result.isFlea = true;
    result.canFlyInAir = true;
    result.entityID = entityID;
    return result;
  }
  void addAirCraft(ref Entity aircraft) {
    if (aircraft.canFlyInAir && this.isAircraftCarrier) {
      aircraft.opt_parentID = this.entityID;
      this.opt_numOfAircrafts++;
    }
  }
  void woof() {
    if (isDog) {
      if (isAircraftCarrier) writeln("I'm a motherfucking aircraft carrier");
      else writeln("Woof!");
    }
  }
}

void main() {
  Entity dog = Entity.createDog(1);
  Entity flea = Entity.createFlea(2);
  dog.woof();
  dog.isAircraftCarrier = true;
  dog.addAirCraft(flea);
  dog.woof();
}
[โ€“] a_jackal@pawb.social 4 points 15 hours ago

You forgot the component part.