SDL Motion/Visual studio?
Posted: Sat Oct 01, 2011 2:39 am
So, I'm trying to make pong... I've got a lot of the none flashy stuff setup but I'm having one problem - My motion is acting weird, it's only moving one pixel and then it stops>UNLESSSS for some reason I move the mouse and then it works for which I have no idea...
Here's my main loop:
Here is the blit() member function:
Here's the moveUp() function, the moveDown() function is almost identical:
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.
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.