Public Group

# SDL Co-ordinates

This topic is 2924 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey Guys,
My major problem is I always get confused when drawing a image onto the screen in SDL, I know that SDL coordinates are not as regular as in the real world, But my doubt is suppose, if i draw a square onto SDL coordinates in x and y axis. How will i calculate its offsets, This confuses me alot sometimes.

##### Share on other sites
SDL coordinates are like most graphic engine coordinates, they start at the top left corner of your screen/window. The more you go down the screen the Y increases and as you go across to the right the X increases

Ex. If you want an image in the top left corner set its X to 0 and it's Y to 0
This way the top left corner of the image will be at the top left corner of te screen.

##### Share on other sites
Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.

##### Share on other sites

Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.

Not sure if by "screen" you mean the physical display, or the window in which you are drawing. If you mean the window, placing a square at (200, 200) will appear at (200, 200) in the window, as long as the square's coordinates are zero indexed. If you mean the display, then unless the SDL screen surface is fullscreen, you are constrained by drawing in the window. All coordinates are relative to the window's origin.

##### Share on other sites
And also, If you draw a Sprite at position (200,200) for example, That means that the images top left corner is set at that position. Unless you transform it's origin.

The way I remember the Y direction is:

A girl goes down in front of you = positive
[/quote]

##### Share on other sites

The way I remember the Y direction is:

A girl goes down in front of you = positive

[/quote]

lol

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 36
• 16
• 75