- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/jegan/Desktop/projectX/Control.cpp

Go to the documentation of this file.

    00001 #include <algorithm>
    00002
    00003 #include "Control.h"
    00004 #include "Screen.h"
    00005
    00006 using namespace std;
    00007
    00008 vector< Object* > Control::_controllers;
    00009
    00010 SDLKey Control::upKey = SDLK_UP;
    00011 SDLKey Control::downKey = SDLK_DOWN;
    00012 SDLKey Control::leftKey = SDLK_LEFT;
    00013 SDLKey Control::rightKey = SDLK_RIGHT;
    00014 SDLKey Control::shoot1Key = SDLK_LCTRL;
    00015 SDLKey Control::shoot2Key = SDLK_RCTRL;
    00016 SDLKey Control::altShoot1Key = SDLK_LALT;
    00017 SDLKey Control::altShoot2Key = SDLK_RALT;
    00018 SDLKey Control::jumpKey = SDLK_SPACE;
    00019 SDLKey Control::skipKey = SDLK_SPACE;
    00020 SDLKey Control::quitKey = SDLK_ESCAPE;
    00021 SDLKey Control::menuUpKey = SDLK_UP;
    00022 SDLKey Control::menuDownKey = SDLK_DOWN;
    00023 SDLKey Control::selectKey = SDLK_SPACE;
    00024
    00025 void Control::update()
    00026 {
    00027         /*
    00028         for( vector< Object* >::iterator i = _controllers.begin(); i != _controllers.end(); i++ )
    00029         {
    00030                 (*i)->control();
    00031         }*/
    00032         for(size_t i = 0; i < _controllers.size(); i++)
    00033                 _controllers[i]->control();
    00034 }
    00035
    00036 void Control::registerController(Object * o)
    00037 {
    00038         _controllers.push_back( o );
    00039 }
    00040
    00041 void Control::detachController( Object* o )
    00042 {
    00043         // It's possible that the controller is registered multiple times, so
    00044         // remove all instances
    00045         _controllers.erase(
    00046                 remove( _controllers.begin(), _controllers.end(), o ),
    00047                 _controllers.end() );
    00048 }
    00049
    00050 void Control::detachAllControllers()
    00051 {
    00052         _controllers.clear();
    00053 }
    00054
    00055 /*void Control::setKeys(std::string filename)
    00056 {
    00057         List * keyInfo = Parser::parse(filename);
    00058
    00059         keyInfo = keyInfo->rest();
    00060         while(!keyInfo->empty())
    00061         {
    00062                 List * current = menuInfo->firstList();
    00063                 menuInfo = menuInfo->rest();
    00064
    00065                 if(current->firstString() == "up")
    00066                 {
    00067                         current = current->rest();
    00068                         _options.push_back(new Menu(current->firstString()));
    00069                 }
    00070
    00071                 delete current;
    00072         }
    00073 }*/
    00074