I jsut found one of the worst possible ways to build a game engine

Started by
16 comments, last by Promit 22 years, 3 months ago
Sprite implies animation, which is not what your sprite class does. A camera isn''t a sprite, but it is a node in the scene graph, which is what your sprite class appears to actually represent.

Starting with one pure virtual base class is the SI mindset; it''s not necessary with MI. A common base interface is often useful, but all the other interfaces don''t need to derive from it.

Several commercial engines use a virual render function that is called for objects such as (a real) CSprite, CTerrain, etc...
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
Doesn''t anyone remeber the "Is A", "Has A" relationship lecture from the early college programming classes.

A Car "has" 4 tires.. so it doesn''t make sense to inherit a tires class from car class. The Car Class should contain 4 "tire" class objects.

A car "is" an automobile so is a truck, or an RV. So it makes sence to inherit a "Car" class from an "automobile" class.

quote:Original post by Ironside
A car "is" an automobile so is a truck, or an RV. So it makes sence to inherit a "Car" class from an "automobile" class.

So does an automobile have 4 tires?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by Magmai Kai Holmlor
So does an automobile have 4 tires?

Good job on that one!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
I''m waiting on the "Is a"/"Has a" lecture when I do my first OOP unit this coming semester, but wouldn''t an Automobile have -no- tires, and you''d leave it up to the derived classes to decide how many tire classes they''d include?
http://www.deakin.edu.au/~bradleyj/unsanity/
  std::vector<CTire*> m_vctTires;  
It all depends on what you want to do. If you want to force the automobile to have 4 tires, go with it, but you can leave it up to the one who will inherit the class. Will an automobile run if there is no tire? probably not, so you''d better put the tires there. If the inherited class needs more (or less) tires, it can overload the methods. (maybe with some tricky stuff, it depends on how it''s designed at the begining)
I was aware that i screwed up the Is-A relationships pretty badly, and the naming as well. It was a 2 hour long experiment in high levels of inheritance, to see just what the result would be. It was terrible.

Ive been doing research in interfacing and seeing what type of interface and setup works best. When that''s totally done, I''ll put all the code into a nice format.

The relationships are going to stand at CObject-CSprite-[Specific Object] i think. THe camera class is going to rotate and move somewhat differently from world sprites. Each camera will store it''s own matrix. The pipeline class will have an internal pointer to the camera that is to be used, and use it''s matrix for the view transform. The pipeline will also manage the top of the my frame-based hierarchy, and will allow direct access to the hierarchy if one needs it. There''ll be a mesh class in Specific object, which will probaly manage either a CD3DMesh(part of DX Common files), or directly deal with an ID3DXMesh. Not totally sure yet. Or i could use a union. But so theres the general break down.

Comments?

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement