Monday, September 25, 2017

architecture - How can I separate entities from their actions or behaviours?


I'm having a go at creating a very simple text based game and I'm wondering how I can design the entities (characters, sentient scenery) with regards to the actions those entities can perform.


As an example, I have an entity that is a 'person' with various properties such as age, gender, height, etc. This 'person' can also perform some actions such as speaking, walking, jumping, flying, etc etc.


How would you separate out the entity from the actions it can perform?



Answer



The common answer you'll get is "with components". There are lots of questions with that phrase in them that you can search through.


In particular, here's a good article that has been linked to several times that's worth a read: http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...