Should game actors know what level they're on?

Started by
0 comments, last by Extrarius 15 years, 5 months ago
Suppose I have a Game object that keeps track of the player's avatar, which is of class Actor, and the current level, which is of type Level (of course). Events from the game controls are passed to the Game object, which then gives actions to the player's Actor like moving or attacking. The Level stores all of the Actors that are one it, and the Game takes the Actors that are not the player and makes them run their AIs each update. Right now, in addition to the Level keeping track of the Actors that are on it and their locations, each Actor has a pointer to its Level and its own location. I'm wondering if I really need to store Level location in an Actor. I had Actors know their Levels for the sake of an Actor's AI and for the sake of the game GUI in the case of the player Actor. However, the GUI interfaces with the Game, and the Game would already store the current level (where the player is). As for the AI, I could just pass the current level to an AI's update function. Then again, I'm not really sure yet how the AIs will be structured in relation to the Actors and the Game. The only time I'm starting to think Actors knowing their Levels would be useful is if I had more than one Level in memory at the same time. What do you think?
Advertisement
Why do the Actors need a level to act? It sounds like the 'Level' type is filling a great number of roles from spatial partitioning to environmental awareness to storing static geometry. You might want to break it into multiple types that each handle a single responsibility.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement