user6629882
user6629882

Reputation:

C++ SDL x and y axis on SDL_Rect

I'm working with the SDL library for C++.
When I change the x and y values, I can get my rectangle to move around, but not in the manner I'm expecting.
For example, it moves down with a larger y coordinate.
Why is this?

//Render rectangle (xPos, yPos, width, height) using constants.
SDL_Rect fillRect = { S_WIDTH / 4, S_HEIGHT / 4, S_WIDTH / 2, S_HEIGHT / 2 };

Upvotes: 1

Views: 1999

Answers (1)

skypjack
skypjack

Reputation: 50550

Coordinate system in SDL is top-left (that is, (0, 0) is placed in the top-left corner).
Because of that, x goes from left to right, y from top to down.
Greater the value of y, (let me say) lower the position of the rectangle.
That's all. It works as expected. It's a matter of what you were expecting and that was wrong.

Upvotes: 1

Related Questions