Sign in to follow this  
  • entries
    162
  • comments
    262
  • views
    167100

Beginnings of an idea...

Sign in to follow this  

90 views

After much indecision, I'm ended up writing down how I wanted the code to 'look' from a usage point of view, and designed (read: improvised) a back end which would do this nicely. This usually tends to give me good results when I can't see an obvious way to do things. Unfortunatly it can miss out some more obscure or unexpected edge cases, but those can usually be worked out later (when I've got a good grip on what actually needs to be done).

In this case I've got a fairly heavy emphasis on using names to build stuff from a factory, eg: (psedo code)

spawnEnemy(Config config)
e = EnemyFactory.create(config.enemyName)
w = weapons.find(config.weaponName)
if (!w)
w = WeaponFactory.create(config.weaponType)
e.setWeapon(w)

What this leaves me with is a way of defining radically different configs, all hidden away inside the factories and created by just using the appropriate name string. This leaves the actual in-game code to just worry about *when* to create stuff, not how.

Its all very hardcoded for now, but eventually these configs will be pulled from xml files or similar. The factories themselves will probably also use xml to define variations on the major types provided.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now