Here's my main loop:
Code: Select all
Uint8 *keystates = NULL;
while(run == true)
{
keystates = SDL_GetKeyState(NULL);
while(SDL_PollEvent(&events))
{
if(keystates[SDLK_UP])
{
player.moveUp();
}
if(keystates[SDLK_DOWN])
{
player.moveDown();
}
if(events.type == SDL_QUIT)
{
run = false;
}
}
background.blit();
player.blit();
SDL_Flip(General::screen);
SDL_Delay(1);
}
Code: Select all
void Entity::blit()
{
SDL_BlitSurface(image,NULL,General::screen,&offset);
}
Here's the moveUp() function, the moveDown() function is almost identical:
Code: Select all
void Padel::moveUp()
{
if(offset.y != General::YPADDING)
{
offset.y -= 10;
}
}
From what I've done on linux, and looking at the lazy foo tutorial it looks almost identical, but it's not working right in visual studio?
It works when I move the mouse, however.