• bstix@feddit.dk
    link
    fedilink
    English
    arrow-up
    8
    ·
    9 days ago

    Objects are great for game programming.

    Stuff like enemies, bullets, loot, items, etc. are constantly changing and affecting each other. This makes it difficult to program in fixed functions that run through and crosscheck a bunch of constantly changing arrays. It makes logical sense to have objects with their own functions stored in dynamic lists instead of arrays. A lot of the properties are used by several different objecs, like coordinates or health points, so it also makes sense to describe them in classes.

    So, I’d say that it’s a useful way to classify data that is very dynamic, or when different functions need to run depending on that data.

    I don’t like putting all code into classes, because a lot of code doesn’t need that kind of flexibility.