I've been working on some 2D Movement in my games for the last few weeks and i'm using the SDL game libary for this game. I have a
Player class with a SDL_Rect embedded in it for tracking x,y coordinates. The problem is that my Player will not move because my Input() method does not change the X Value. After doing some debugging, I figured out that my Input()method works and my Draw()method also works, but the Input()method does not change the values at all.Input():
void Input(SDL_Rect Rect)
{
SDL_Event Event;
while(SDL_PollEvent(&Event))
{
if(Event.type == SDL_KEYDOWN)
{
if(Key == SDLK_LEFT)
{
Rect.x--;
}
if(Key == SDLK_RIGHT)
{
Rect.x++;
}
}
if(Event.type == SDL_QUIT)
{
Exit();
}
}
}