0

Does anyone know where I can find "good" examples of abstract factory pattern as it would relate to game development specifically RPG game development? I'm not looking for things I can copy, but just for different examples that diagram various solutions to help me better understand how i would implement the abstract factory pattern in an text based rpg Thank you ahead of time

Keith Beard
  • 1,601
  • 4
  • 18
  • 36
  • 1
    A better question is what are you looking to do with your abstract factory? Monsters? Items? Quests? Damsels in distress? The abstract factory pattern doesn't relate just to game-dev. The examples you find will be applicable to all areas of expertise. – corsiKa Mar 03 '11 at 21:23
  • Remember one thing: RPG programming does not differ from programming in general. Just have a look at other examples of this pattern, if you see processes in your application (e.g. RPG) conforming to this pattern, you can apply it. Pattern is just a tool that makes it easier for you to solve problems. – vissi Mar 03 '11 at 21:32
  • Probably just monsters and items, no quests this will be simple turn based fighting monster drops item you pick up itm an integer for str or dex increases you move on the screen to the next monster. I should have mentioned i am new to this, i can write a bit of code and have built a few application,. But honestly i dont remember much about OOP and i just have a task to create simple text based fighting game using the factory pattern. Well i wrote the game using a bunch of classes, i just didnt use any interfaces or "factory classes" – Keith Beard Mar 03 '11 at 22:02
  • so i just have to get my head wrapped around the concept, which how a diagram could have really helped, something more specific than you would find going to aboout 50 sites on google – Keith Beard Mar 03 '11 at 22:03

1 Answers1

1

Here is an object-oriented MUD codebase in Lua...

 http://sourceforge.net/projects/lune/

Not sure if it uses an abstract factory but you could certainly take a look, might also be helpful to check out some other codebases.

An example that comes to mind is if you can create a character with a class (no pun intended), you could have a CharacterFactory, and RougeFactory and DruidFactory implementing CharacterFactory, each having a different implementation the attack() method.

The example given on Wikipedia,

http://en.wikipedia.org/wiki/Abstract_factory_pattern

can easily be adapted to suit a variety of RPG development situations.

Brandon Frohbieter
  • 17,563
  • 3
  • 40
  • 62
  • I was thinking the same thing, that the pattern could be applied to the creature creation, was wondering would it be bad to create a class that held all my variables, would it affect the OOP principals of the abstract factory ? – Keith Beard Mar 03 '11 at 21:30
  • The parent 'creature' could have variables that all created creatures would inherit. This is harmonious with the principles of the abstract factory. – Brandon Frohbieter Mar 03 '11 at 21:33