this post was submitted on 13 Nov 2024
791 points (96.1% liked)
Greentext
4383 readers
1347 users here now
This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.
Be warned:
- Anon is often crazy.
- Anon is often depressed.
- Anon frequently shares thoughts that are immature, offensive, or incomprehensible.
If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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.