Skip to main content
gamedev.net
🔒 Locked

OOP Question

Started by doogle 1 reply 300+ views
Original Post
doogle
doogle
Just a simple question about the design of a program... Say I had a class TMonster, but all my ddraw function are in another class. Should I a) Make a function, TMonster::DrawMonster() and include the class with the ddraw functions. b) Make the class with the ddraw functions draw the monster and have the TMonster x,y etc values public? Hope this makes sense.
Guardian_Light
Guardian_Light
The answer is a, but consider the following:

If your monster *has* the ability to draw itself from creation onward, you should send a pointer of your drawing object with the monsters constructor, so the monster can draw himself when he wishes. Of course, this may not be economical for a game engine, but it's somthing to consider.

"So much fun, so little time."
~Michael Sikora

Edited by - guardian_light on November 26, 2001 6:56:50 PM
Artificial Life
Artificial Life
I only can agree with Guardian_Light. I would create a screen class which contains a pointer to the base class of the monsters. Then, the screen class can enumerate the elements of the monster array and call its draw function. Now, you only have to overload the draw function for every class inherited from the monster class.
Success is not the position you stand but the direction in which you look

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.