It depends on what you mean by "draw yourself." If you mean, if it contains low-level routines involving pixels or triangles, then probably not.
My suggestion:
- One class to represent the behavior of an object (motion, AI, whatever)
- One class to represent the appearance of an object
- One class for defining an object as a combination of appearance and behavior
If the "appearance" includes some kind of custom drawing procedure, which may be in this class. In general, although the drawing could be abstracted from the core API, perhaps using a strategy, a visitor, or some IoC template, the object would be drawn by some rendering manager. This is especially true in game design, where things such as sharing textures to / from video memory and drawing things in the correct order are important; something should be able to optimize things above the level of the object.
To try to be more specific, one part of your object graph (the object itself or the object break) implements IRenderable
, has a Draw(IRenderEngine)
method, and that IRenderEngine
provides IRenderable
access to methods such as IRenderable
t24>, CreateParticleEffect
or whatever. Optimizing or measuring your engine and algorithms will be much easier, and if you need to swap engines or rewrite them in an uncontrolled, high-performance way (or port to another platform), just create a new implementation of IRenderEngine
.
Hint: if you do this, you can have many things that look the same / similar, but act differently, replacing the behavior, or many things that look different, but act the same. You can also have the behavior of things on the server, and the look is happening on the client.
I did something very similar to this before. Each object class had a base class that contained the properties used on the client, but on the server it was a derived instance of this class that was created and included behavior (movement, simulation, etc.). The class also had a factory method for providing its associated IRenderable interface (appearance). In fact, in the end there was a fairly effective multiplayer game engine.