Skip to content

Instantly share code, notes, and snippets.

@donalmacc
Created March 12, 2013 13:07
Show Gist options
  • Save donalmacc/5142731 to your computer and use it in GitHub Desktop.
Save donalmacc/5142731 to your computer and use it in GitHub Desktop.
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