Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a first person dungeon crawler like Eye of the Beholder.

During execution, I have a Map object. It contains Cell objects. Anc each Cell contains, at most, four Wall objects.

The Wall object has data for it's texture, and special elements like a door, a switch, etc. But most walls will end up being empty, boring walls.

My idea is to make this "boring wall" a single instance, that is referenced by all the cells that need it. Is there any design pattern or recipe in how to work with this? Or do you have any ideas?

I would like the entity's usability to be the same as the remaining entities (although I realise the default instance must be immutable).

I don't know if it helps, but I'm working with Lua.

Thanks in advance.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

is the pattern name if I'm reading your question correctly.

share|improve this answer
    
It's not quite what I want, but I can start from here. Thanks. –  Vasco Correia May 13 at 16:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.