Created
March 12, 2013 13:07
-
-
Save donalmacc/5142731 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool keys[255]; | |
// constructor | |
EventHandler::EventHandler() | |
{ | |
for(int i = 0; i < 255; i++) | |
keys[i] = false; | |
} | |
EventHandler::keyPressed(unsigned char key) | |
{ | |
keys[key] = true; | |
} | |
EventHandler::keyReleased(unsigned char key) | |
{ | |
keys[key] = false;' | |
} | |
// in your update loop | |
void GameClass::updateEverythingLoop() | |
{ | |
bool* kh = eh->getKeys(); // returns a pointer to the keys, which you know is an array of size 255. | |
if(kh[SDL_UP_ARROW]) | |
player->moveUp(); | |
elseif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment