🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

2D Game Engine Design & clipping

Started by
0 comments, last by period3 24 years, 6 months ago
I am currently working on constructing a sensible 2D engine using Visual C++. One of my goals is to have the engine be re-usable and easy. I currently have the following classes (well, these are the relevant ones): Texture //a texture to be applied to an Object2D Object2D //a better name for this would have been Polygon AffineTransform //rotations, translations, etc. Matrix3x3 //3x3 matrix math. World //a collection of entities in world-space. Entity //a collection of objects. I''m having a few problems coming up with a sensible solution of getting an object from object-space onto the screen. Logically, it makes sense to have the world as a collection of entities (eg. the "world" is every entity currently existing.) IF this is done, everything works fine except I end up with a slow bottle neck when I go from world-space to view-space. (eg. clipping the world so it fits on the screen. I''m probably misusing some 3d lingo here, but basically world-space ->viewspace -> screen is pretty much all one step) The problem is, short of testing every entity (which would then involve testing every Object2D (polygon) ), how do I determine which objects are visible? I was thinking of calling a refreshVisibile() function to test everything and determining the visible entities. Then, I would only need to test an object if it is moved (to see if it''s gone off or on the screen.) Does this sound like a reasonable approach? Basically, I know how to do it slowly, but i''m not sure how to do it quickly. Are there ANY object oriented 2D engines out there?
.3
Advertisement
If you test every entity, you don''t need to test every Object2D. Just put a bounding box around your entity and check to see if the bounding box would be on screen. Two (or more) entities that are close to one another could have another bounding box around them. Then if that bounding box is offscreen all the entities are offscreen. Move on to next group.

This topic is closed to new replies.

Advertisement