🎉 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!

More Design...

posted in A Keyboard and the Truth for project 96 Mill
Published July 13, 2007
Advertisement
So I did some more tinkering and contemplation last night; I discovered that while the strict tree structure of 'State Nodes' at first seemed ideal, it led to a few weird inconsistancies; e.g. having a render function echo through _all_ of it's children would not be ideal if calling render from the root of the gamestate (the world object), which contains multiple rooms, we wouldn't want to render all rooms, just the one we're looking at, this would require overriding the render method in world, and doing the echo customly starting with the 'currentRoom'; this need for fine tuning via overridden funtions seemed to lessen the elegance of the strucutre, so instead I decided to go with a closer model to what the S3Engine used:


class StateObject{private:	unsigned long id;//index to engine objects array?	std::string scriptFile;//filename of script to usepublic:	virtual void save(OutputArchive& oa);	virtual void load(InputArchive& ia);	virtual void update(void);	virtual void render(RenderingBatch& rb);};class Engine{public:	std::vector> objects;//full list of objectspublic:	void saveGame(const std::string& fileName);//head-method for world->save	void loadGame(const std::string& fileName);//head-method for world->load	SharedPtr getWorld(void);//returns index 0 from objects table};class World: public StateObject{public:	std::vector> rooms;	SharedPtr currentRoom;	SharedPtr watchedActor;	SharedPtr currentActor;	public:	void save(OutputArchive& oa);	void load(InputArchive& ia);	void update(void);	void render(RenderingBatch& rb);};class Room: public StateObject{public:	std::vector> actors;public:	void save(OutputArchive& oa);	void load(InputArchive& ia);	void update(void);	void render(RenderingBatch& rb);};class Actor: public StateObject{public:	SharedPtr room;public:	void save(OutputArchive& oa);	void load(InputArchive& ia);	void update(void);	void render(RenderingBatch& rb);};



The main difference is that the World object inherits from StateObject wherein this was not the case in the S3Engine. By having a tree-ish structure by each node subclass having it's own potential set of custom children, gets rid of the 'one-size-fits-all' approach of having a straight Children array.

The StateObject contains base functions for serialization(save/load), update (simulation time progression) and Render(visual reperesentation), it also contains the id (which is a direct index to the linear object store for easy retriveal) and a scriptFile string; each State object will have a potential script associated with them to provide custom coding for events the object raises.

So far so good :D

Thoughts? Comments?
Previous Entry Progress Too Slow!
Next Entry Research
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement