views:

295

answers:

2

I want a clean way of creating game object such as NPCs, bullets and power-ups, reducing the amount of inter-dependence on specific classes. I believe this is what the factory pattern is used for?

I would love to see a good implementation from a real game.

I'm not an expert on design patterns, and never use them if I don't understand them. I don't want to use a design pattern for the sake of it - I just want to understand if this pattern is the right way to solve this problem.

+3  A: 

It looks you are trying to find the problem to the solution.

On this particulary question it is nog really possible to give a good implemention because it deponds on how your game objects are stored, what they represent.

You should not try to look for how to implement a specific pattern to a problem, but to find the right sollution to your problem, and that might be a design pattern.

Ikke
Agreed, I don't want to use a design pattern for the sake of it - I want a clean way of creating game object such as NPCs, bullets and power-ups, reducing the amount of inter-dependence on specific classes.
Iain
But that's a different question. You should ask how to design gameobjects. Now you just ask for a specific design pattern, which may not be suited at all.
Ikke
+1  A: 

After some more googling I Actually found a pretty good example:

http://cheezeworld.com/object-creation-game-factory/

thanks all

Iain