Skip to main content

Design Help - Object Manager

Submitted by Jacana on
Forum

Just wanted to get some feedback for a better way to design an Object Manager. This was from one of my assignments last year I want to clean up and the object storage is shocking.

What I have now:
Object Manager
StaticObject staticObj[STATIC_NUMBER]
DynamicObject dynamicObj[DYNAMIC_NUMBER]
PlayerObject playerObj[PLAYER_NUMBER]

So basicly the object manager sets up the static, dynamic, and player objects and holds an arry of each as well as reading in file information for the static objects and created the databases for the different object types.

Static objects have set positions.
Dynamic objects have random positions.
Player objects is the player (only single player).

ATM the code is quite nasty - the assignment was only 3 weeks :) But I am keen to try and clean it up so that I can use it as a test bed to play with other things.

Really - I was just wondering about how people would set up an object manager design and what type of storage you'd use.

Submitted by Barry Dahlberg on Sun, 28/03/04 - 9:09 PM Permalink

Is for managing objects during the execution of a game or for storage between or a mix?

I tend to use something more dynamic than fixed arrays for storing the objects but there's pros and cons to that. Do alot of objects get created and deleted while running or is it fairly static?

Submitted by Jacana on Sun, 28/03/04 - 9:16 PM Permalink

Managing during execution - main thing it would be for would be running collision tests on objects etc really.

The objects are fairly static - there's only something like 5 of the objects which the player can "pick up" and when they do that I just make those objects invisible since they can "respawn" later.

Submitted by alia on Sun, 28/03/04 - 10:47 PM Permalink

How about a map with the object ID and an object pointer? you could derive the objects from the same class:

class Object{
ID object_id;
TYPE object type; // (static/dynamic/plr)
... (object data)
}

map< ID, object *> blah

then to updatee just iterate through the map
to do collision test - iterate trhough with two iteraters.. etc

quick and _dirty_ :)

A.

Posted by Jacana on
Forum

Just wanted to get some feedback for a better way to design an Object Manager. This was from one of my assignments last year I want to clean up and the object storage is shocking.

What I have now:
Object Manager
StaticObject staticObj[STATIC_NUMBER]
DynamicObject dynamicObj[DYNAMIC_NUMBER]
PlayerObject playerObj[PLAYER_NUMBER]

So basicly the object manager sets up the static, dynamic, and player objects and holds an arry of each as well as reading in file information for the static objects and created the databases for the different object types.

Static objects have set positions.
Dynamic objects have random positions.
Player objects is the player (only single player).

ATM the code is quite nasty - the assignment was only 3 weeks :) But I am keen to try and clean it up so that I can use it as a test bed to play with other things.

Really - I was just wondering about how people would set up an object manager design and what type of storage you'd use.


Submitted by Barry Dahlberg on Sun, 28/03/04 - 9:09 PM Permalink

Is for managing objects during the execution of a game or for storage between or a mix?

I tend to use something more dynamic than fixed arrays for storing the objects but there's pros and cons to that. Do alot of objects get created and deleted while running or is it fairly static?

Submitted by Jacana on Sun, 28/03/04 - 9:16 PM Permalink

Managing during execution - main thing it would be for would be running collision tests on objects etc really.

The objects are fairly static - there's only something like 5 of the objects which the player can "pick up" and when they do that I just make those objects invisible since they can "respawn" later.

Submitted by alia on Sun, 28/03/04 - 10:47 PM Permalink

How about a map with the object ID and an object pointer? you could derive the objects from the same class:

class Object{
ID object_id;
TYPE object type; // (static/dynamic/plr)
... (object data)
}

map< ID, object *> blah

then to updatee just iterate through the map
to do collision test - iterate trhough with two iteraters.. etc

quick and _dirty_ :)

A.