- Implementat keyPressed
This commit is contained in:
@@ -24,24 +24,24 @@ int main(int argc, char *argv[])
|
||||
SDL_Event e;
|
||||
while (!should_exit)
|
||||
{
|
||||
uint8_t keyp=SDL_SCANCODE_UNKNOWN, keydown=SDL_SCANCODE_UNKNOWN;
|
||||
while(SDL_PollEvent(&e))
|
||||
{
|
||||
if (e.type==SDL_QUIT) { should_exit = true; break; }
|
||||
if (e.type==SDL_KEYDOWN)
|
||||
{
|
||||
keydown = e.key.keysym.scancode;
|
||||
input::updateKey(e.key.keysym.scancode);
|
||||
}
|
||||
if (e.type==SDL_KEYUP)
|
||||
{
|
||||
keyp = e.key.keysym.scancode;
|
||||
input::updateKeypressed(e.key.keysym.scancode);
|
||||
}
|
||||
}
|
||||
input::update(keydown,keyp);
|
||||
|
||||
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)
|
||||
{
|
||||
if (!game::loop()) should_exit = true;
|
||||
input::updateKey(SDL_SCANCODE_UNKNOWN);
|
||||
input::updateKeypressed(SDL_SCANCODE_UNKNOWN);
|
||||
current_ticks = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user