• entries
162
262
• views
167216

# Beginnings of an idea...

96 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.

There are no comments to display.