When I decided to teach myself to program, I started with Java. And although I'm familiar with writing simple procedural software (mostly in PHP), I've recently come to realize that for more complex operations I rely on objects.
My first Java game spawned opponents at random locations and with random speeds by instantiating objects. I am puzzled by the concept of implementing this procedurally in C (which I have very little working knowledge of), but I could only think of creating different arrays for the variables in each opponent and using the array indices as pseudo-object reference 'variables'.
int size[50]; // opponent size
for (i = 0; i < 100; i++) {
size[i] = random_number();
}
Is there a simple solution that my object-oriented mind has overlooked? Or do certain problems really lend themselves to object-oriented concepts to the extent that you have to make up fake objects (or at least use similar models)? I see structs in C code all the time, and I know they're similar to classes in concept, but that's all I know. So I'm wondering if stuff like this is possible with a totally non object-oriented mindset. There's no real substitute for instantiation, is there? It's all just allocation of memory, so the way I see it, certain C programs have no choice but to be written using some form of what I consider objects.
Please tell me I'm overlooking something, because otherwise I can't respect C purists who berate the object-oriented paradigm. (I'm by no means an OO nut; my mind has become very accustomed to the idea, though, and it's hard to see things through a different lens that doesn't offer what you're used to.)
Thanks!