OOP - Missing Link?

Started by
3 comments, last by TIMPAN 18 years, 3 months ago
Hello all. I have been programming off and on for a few years now, mostly in C/C++ for the last couple. I seem to be missing the ability to program a game in an object oriented fashion. I think what is really hindering my ability to do this is that I don't have a clear understanding of the way in which these classes should interact with each other. Most of the time when I try and use classes, I get a set of classes that are being used in a procedural way. Any thoughts on how to get over this? I understand the basics of OOP but seem to not be able to get to that next level. Thanks ~Casey~
Advertisement
Surely you could have something like

Character::

and

Weapon::

and

Level::

then have the Character:: interact with Level::

???
Understanding how 'virtual' enables you to eliminate the vast majority of 'if-then-else' and 'switch' statements would do you some good. That understanding helped me immensely. I do not know if the word 'immense' is great enough to properly express what I mean. 'virtual' is *VERY* powerful.

Instead of something like:

fireWeapon(Weapon * w) {
switch (w->type()) {
case Weapon::Gun:
fireGun();
break;
case Weapon::laser:
fireLaser();
break;
...
you do something like:
weapon->fire();
The simplification is enormous.
You want (at least) chapters 7, 10, 11, 19, 20, 21, 28 and probably 29, although I would recommend reading the whole thing if you can.
http://www.gamedev.net/community/forums/topic.asp?topic_id=366513

pretty recent, aloy, hope it clears something up for you as it did for me.

=)

This topic is closed to new replies.

Advertisement