Sign in to follow this  
Gerbert

Should game actors know what level they're on?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this