I start to learn design-patterns. I understand that prototype is for making an exact copy of an object I already have and Flyweight is for making similar objects... I programmed 2D platformer game like Mario (in Java). There are a lot of enemies which are the same the only difference is their position [x,y]. There are also walls which are built from a huge number of rectangles and again the only difference is their position [x,y].
Is it vice to use some of these design patterns in this particular situation ? Should I use prototype to clone objects via clonable and then set [x,y] ? or it's better to use flyweight - when I need new object I just return them from my hashmap and then set [x,y]. In both scenarios I avoid using new operator but I am not sure which one to use... Thanks
Aucun commentaire:
Enregistrer un commentaire