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 [font=courier new,courier,monospace]Player[font=arial,helvetica,sans-serif] class with a SDL_Rect embedded in it for tracking x,y coordinates. The problem is that my Player will not move because my [font=courier new,courier,monospace]Input()[font=arial,helvetica,sans-serif] method does not change the X Value. After doing some debugging, I figured out that my [font=courier new,courier,monospace]Input()[font=arial,helvetica,sans-serif]method[/font][/font] works and my [font=courier new,courier,monospace]Draw()[font=arial,helvetica,sans-serif]method also works, but the [font=courier new,courier,monospace]Input()[font=arial,helvetica,sans-serif]method does not change the values at all.[/font][/font][/font][/font][/font][/font][/font][/font]
You pass the SDL_Rect by value so the changes to Rect will not be visible from outside the function. Instead pass a reference or a pointer. void Input(SDL_Rect Rect)
{
...
You pass the SDL_Rect by value so the changes to Rect will not be visible from outside the function. Instead pass a reference or a pointer. void Input(SDL_Rect& Rect)
{
...