• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


This topic is now archived and is closed to further replies.


Examples of common Design Patterns in games

3 posts in this topic

I was wondering if people would like to share their usage of Design Patterns in games they have worked on. Looking at the Design Patterns book itself, I can see how they are all useful, but have found that I don''t actually need most of them. But this may just be down to my failure to see the best way of implementing certain features. Therefore I thought it might be handy for people to give some game-oriented examples of how such patterns have come in useful. I use the Composite pattern, or at least some variant of it, in many cases. (Even before I heard it referred to as a pattern as such: I just considered it to be a kind of tree structure.) My custom GUI for my game is built this way, with a base class GUIObject and several descendants such as Screen (the root node), Button, ListBox, Picture (etc...) to provide the various degrees of functionality. The Factory Method pattern is commonly employed for objects that I always need to be stored in some main list. For example, in my game, every Character needs to be stored in the allCharacters list. So instead of having to worry about that every time I create character, I implemented Character::Create() which allocates the Character and adds it to the list before returning the pointer. I am planning to use the Proxy pattern soon to save me some memory usage: currently I load a lot of small files that represent hints and tips for the player. I expect some of these to be used much more than others. They are also used fairly infrequently. So it makes little sense to keep them all in memory, all the time. In future, I will use the proxy object to create my own cache: load them on demand, up to a predetermined maximum, and deallocate the least commonly used when we load a new one. I can see how this could be used for texture management, too. Anybody wish to add their experiences here?

Share this post

Link to post
Share on other sites

During the development of a sound library, I learned that the usage of the FactoryMethod-Pattern was very useful. It was possible to implement a soundbuffer-duplication, in the base class, where I just called the clone()-Method (as it is called in Scott Meyers "More effectice C++") of the derived classes to handle the duplication of the buffer of correct type itself, but logic still stays in the base class.
Also, the Singleton is a great pattern to avoid multiple instances. There is just one active sound listener, and other listener objects are different only by other data, they don´t need an other listener-object. So it is possible to share one (DirectSound-)Listener object with more (C++)-Listener objects.


...and he went forth conquering, and to conquer...

Share this post

Link to post
Share on other sites
For the wrappers for the 3D engine I use, I use the Adapter pattern.

To support undoing of operations client side I use the Command pattern. This is mostly important if you are having a networked game with dead reckoning on the client.

But yes you are right. YOu are not supposed to use Design Patterns for everything. They are just one extra tool for you toolbox of methods you can use to get your things done. Design patterns are not the only right way to do things, but are a handy tool in some cases.

Jacob Marner

Share this post

Link to post
Share on other sites
I use something similiar to a facade/manager pattern often times to manage shared resources (usually files, such as textures). For instance, I have a class called TextureManager which looks like this:

#define TextureHandle int

class TextureManager
//At first, it might seem somewhat dumb just to have

//a fixed size array, but I did it this way mainly so that

//the handles could be direct indices into this list.

//I could imagine this being implemented as a stl map,

//with some modifications to what a TextureHandle is.

Texture* TextureList[MAX_TEXTURES]

//user of the class doesn''t need to work with these, since

//GetTextureHandle does the job of both of these.

TextureHandle AddTexture( char* filename );
TextureHandle TextureExists ( char* filename );

//Finds the handle of the texture if it''s loaded,

//otherwise, it will load the texture and give you a

//handle (in other words, it transparently determines

//whether a file needs to be loaded or not).

TextureHandle GetTextureHandle( char* filename );
void RemoveTexture( TextureHandle );

//Gives you a pointer to a texture in the case that you

//need to modify the texture somehow.

Texture* GetTextureInterface( TextureHandle Handle);


This could probably be extended to work with many other things besides just files, although that''s what I''ve found it to be most usefull for so far. The only real problem with this is the RemoveTexture function, since it invalidates all the handles. Luckily, my engine just draws a blank texture in that case, but it should be handled in a better way (probably with some sort of reference counting scheme).

Share this post

Link to post
Share on other sites