Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Grain

Member Since 08 Apr 2004
Offline Last Active Yesterday, 08:27 PM

#5110617 Digits of Pi

Posted by Grain on 19 November 2013 - 05:16 PM

I'm kind of OCD and irrational numbers really bother me. So how many digits of Pi would you need to calculate a circle the size of the known universe with the accuracy of the Planck length? That way, at least in a physical sense Pi does have a practical end and I can stop worrying about it.


#5080844 Object factory design?

Posted by Grain on 26 July 2013 - 03:54 PM

Every thing in my game world is an Entity, Entity is not derived from anything and has no derived classes. What makes a projectile different from a player, different from an enemy, different from an inanimate object, is what that entity has.  Each Entity has a list of components that it owns. Some components are graphical, some are physical, some are AI components, some are control components(takes player input), ect.

 

I'm trying to use inheritance as little as possible and use a data driven approach. Component is the only class currently that has any derived classes, the 4 I mentioned above. Entity types are defined in a txt file, which is as simple as listing a type name, which components that type has, and any raw values those components may need. 

 

I have a EntityBuilder class that I want to work like this. It first reads that txt file and stores 1 of each type. Then when the worldManager needs a new anything, (projectile, enemy, box, ect.) it asks the Entitybuilder for a new Entity of "type x"  Then the builder looks through it's list of types and and if it finds one  that matches that type name it copies it and passes it to the worldManager. Entity and and each Component implement a copy function, so the EntityBuilder simply calls that copy function on the matching entity(which in turn calls it on each of its components).  In this way I hope to be able to design new stuff for my game world without changing any code and just editing a txt file.

 

I'm not sure if there and actual question in there, maybe just looking for feedback. Also I'm a bit rusty with my design patterns, is this the a factory or prototype pattern?




PARTNERS