Thread: Help with C++ Game Design patterns

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124

    Help with C++ Game Design patterns

    I was taking my old design, and trying to make a better tile game framework to use. I am kind of stuck with some advice or ideas to implement a better way for my input handle class to move or do w.e manipulation for the stage class. Any ideas of what I could do to make my stage and command-input handler class work together?
    Attached Files Attached Files

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Your "stage" is incredibly narrow. An array/list of layers to be drawn in any order is barely more complicated, yet such a form is far more versatile.

    Code:
    State * sStage = new Stage(/**/);
    // ...
    Layer * sLayer = sState->createCompatibleLayer();
    // ...
    sLayer->drawStuff(); // `sStage' draws every layer on "flip"
    Your "inputhandle" seems a pointless form of packing multiple events into a single frame to be later queried. You can pack a series of events which logically group Boolean values into a set over a specified slice of time with transforms provided by the client.

    Code:
    Whatever sCodes = [/* ordered code representing virtual keys */];
    Whatever sKeys = ['w', 'a', 's', 'd'];
    InputHandler * sKeyboard = new InputHandler(/**/);
    // ...
    sKeyboard->filter(sCodes, sKeys, 4);
    // ...
    InputHandlerWrapper sKeysDown(sKeyboard, KEYS_DOWN);
    //
    while(sPlayingGame)
    {
        if(InputHandlerWrapper['w']) // ...
        if(InputHandlerWrapper['a']) // ...
        if(InputHandlerWrapper['s']) // ...
        if(InputHandlerWrapper['d']) // ...
    }
    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Patterns and anti-patterns
    By Neo1 in forum C++ Programming
    Replies: 3
    Last Post: 10-23-2013, 05:30 PM
  2. Useful Design Patterns?
    By h_howee in forum Game Programming
    Replies: 3
    Last Post: 03-31-2010, 03:16 PM
  3. Design patterns in C
    By sashaKap in forum C Programming
    Replies: 2
    Last Post: 04-26-2009, 08:32 AM
  4. Game Design
    By plutoismyhome in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 09-30-2007, 01:22 PM
  5. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM