Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Design Issue

Name: Anonymous 2009-04-03 22:52

Hey /prog/,
I'm having a design Problem.

I'm making a game, and I have an over-arching class (Actor.h) that all objects in the game inherit from. I have a class that loads all objects in the current level from a text file (Level.h), and an object that loads holds and updates all of those objects (Engine.h).

The problem is, when each class shoots, I need to load the bullet from the actor object into the Engine, which holds a vector of Actors. Seeing as a bullet is derived from an Actor, including bullets in the original Actor object is not an option, and even if I could, including the Engine object in Actor would cause another circular inclusion (Engine would hold a vector of Actors, and Actor hold the main engine).

The whole power of the engine I"m trying to make hinges on being able to keep all the objects in one vector, as I thought up an algorithm that allows me to check only every third object if it's hitting something, speeding up the gameplay.

So, any ideas? Here's a shitty diagram I made while trying to think this out:
                                Game.cpp
                                   ||
                                  /  \
                      Screen.h--Level.h
                                       ||
                                Engine.h
                       ||
                         \
                      Vector of Actors <-|
                             ||          ||Bullets.
                               Actors--------|

Name: Anonymous 2009-04-04 0:15

So, what's so great about putting everything into one vector? Seems like it's just causing you trouble (not that it should, but apparently it did).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List